Sleeper agents are probably as old as espionage; the idea of having an individual in place among the enemy, not actively doing anything but prepared and able to do something when instructed, is strategically sound and there are too many examples to easily count.
The idea of a sleeper agent that needs to be awakened in the sense you're talking about is a much more contemporary concept that emerged during the Cold War. In 1950, journalist Edward Hunter coined the term "brainwashing" to refer to what the Chinese government practices for conditioning subjects to behave in certain manner - like getting prisoners of war to read statements denouncing their government, or professing loyalty, etc.
The roots of this idea go back very deeply, as there are plenty of examples of confession under torture, and on the more fictional side of things the idea that hypnotism (or animal magnetism, Mesmerism, etc.) can change behavior or thought patterns. George Orwell in Nineteen Eighty-Four: A Novel (1949) had focused on the idea of different ways governments could control and influence a population, from general propaganda to the focused torture that led to the protagonist declaring "I love Big Brother."
There was some serious scientific research into the idea for a couple of decades, but the popularity of the concept of a sleeper agent that didn't know they were a sleeper agent belongs to The Manchurian Candidate (1959 novel, 1962 film) and The IPPCRESS File (1962 novel, 1965 film), which uses the same basic idea but sort of inverted. The idea has since gone on to be very popular in a number of media.
While there was a lot of interest in psychology in hypnosis and conditioned responses, like the infamous Pavlov's dog experiment, in practice there is no evidence that there is any way to reliably induce such a state of selective amnesia. Most of the hypnotic trances you see on television and the like are at best very temporarily altered state of consciousness where an individual is more open to suggestion.