An ounce of prevention can keep your carpets looking better longer.
That being said what kind of schedule should you have your carpets on?
Frequent vacuuming and keeping as much dirt as possible out of the home are some of the easiest and best things you can do for your carpet.
Daily if possible vacuum the high traffic areas of your home. The entry ways. The middle of rooms such as the livingroom. And also add a small mat at the entry of each door that comes in from the outside. This will keep a great amount of outdoor dirt off of your carpets.
An annual deep cleaning from a professional or from you with a carpet cleaning machine is a good idea. Of course do this at a time when you might be away from your home after the cleaning for several hours or even overnight to allow sufficient drying. Spring is a popular choice as are the winter holidays (you know, guests).
What of spots and messes?
Carpet stains aren't pretty but if you clean as soon as they happen or as soon as possible it makes it much easier in the long run.
To remove stains from your carpet:
Remove as much of the offending matter as possible with a blunt object (plastic knife, spoon etc.) and then blot the rest of the stain with something clean and absorbent like paper towels or a white cloth you have for cleaning (cloth diapers work well too). You want to remove as much of the stain as you can before you start applying your carpet stain removers.
Make sure you you keep an enzyme cleaner on hand if you have pets or babies.
For pet and kid free homes anything by Oxiclean Carpet Spot Stain Remover is a good choice. Their products work well. As of the writing of this article I have two elderly cats and that spells ick! I rely on Simple Solution for Cats and X-O Plus Neutralizer to really get the odor. Both of them work very well for odor eating.
Another good enzyme cleaner is Nature's Miracle.
The key with pet messes is that you have to soak the carpet with the cleaner so it get's through to the pad where the pet mess might have gotten to also. Then you need to let it dry.
If you're in a pinch white vinegar sometimes works well. It also helps to deter the pet from returning to the same spot.
Taking care of your carpets requires continual maintenance. Keep your carpets in good shape. They don't come cheap.