you clean it when it needs cleaning - not before
You can tell it needs cleaning when you get dustspots on your photos - they appear as noticable spots on photos (not like noise) and are usually shown up a lot more when you use a smaller aperture (bigger f number),
Thus its possible to have quite a bit of dust on the sensor and still not need to clean the lens if your shooting wide open- however if your shooting landscapes or macro and use large f numbers (like f13) then you will notice them in your photos sooner.
You can even keep shooting for a good while with them as they are easy to clone out- but its something you don't want to have to do so once they start being a pain its time to clean
For cleaning google DSLR sensor cleaning - there are loads of guides and they all say mostly the same things.
Importantly though NEVER use compessed air to clean the sensor - nor blow into it. Always use something like a Giottos Rocket Air blower and puff it a few times before using it to clean (helps remove and dust or particles inside the blower).
Blow cleans can remove a lot of dust from a sensor and are quite simple to do and preferable to a wipe clean where you have to show some care.
A good tip is to mount your camera on a tripod so that you can have both hands free to clean instead of having to hold the camera up with one