A hamster will 'freeze' temporarily due to fear or surprise. Their eyesight is poor, so they need to listen and sniff to work out what's going on. You can alter your hamster’s environment to make it less stressful. Making sure there are no other pets on the prowl, and keeping sudden noises to a minimum, is a good start.
This 'freezing' behavior is not usually due to a health condition. However, if your hamster does it all the time you might want to get him checked by a vet.
Sometimes hamsters freeze, listening out for danger - the hazard in this photo is obvious enough!
The usual cause of hamsters stopping still is fear. If the pet is new, this is bound to happen in the early days. It will be a strange environment for the pet, and there will lots of new things to get used to. Hamsters are made nervous by threatening noises. This could be something not immediately obvious to you, such as a noise on the TV, cell phone or radio. Like all the rodents, hamsters have very good hearing. Have you watched squirrels 'freeze' in the local park? It's the same thing going on there.
By stopping moving, a hamster can focus its senses on the threatening/unusual sound or smell. In the wild, freezing when they hear a noise allows them to judge whether there's any danger around, reducing their chances of being spotted by a predator.