A Good Rule of Thumb
Changing your hamster's bedding and cleaning the cage out once per week will generally suffice for most situations. Scheduling a weekly cleaning also allows you to set aside a single day, on a weekend, for instance, to establish a general maintenance routine.
Consider Your Hamster
Some hamsters are exceptionally messy. While most tend to urinate and defecate in one favored corner of the cage, some do their business with abandon, wherever they feel like it. In these situations, more frequent cleaning may be needed. Hamsters kept in plastic cages also will need bedding changed more frequently, as they often stuff the plastic tubes with bedding.
Take note of how long it takes for a noticeable odor to be detected when you breathe in near the cage. If any bad scent is present, it's probably a good idea to go ahead and change the bedding, regardless of how recently it was done.