For heavy traffic areas, carpet should be cleaned about every 6 months, and for normal or low traffic areas, once per year.
Whether you have a company out to do it or you tackle it yourself, make sure to use either water only, or a water-based solution mixed with water. Many of the carpet cleaners on the market actually attract dirt making it worse.
I would follow your carpet manufacturer's instructions if you know that info, but I think most say 1-2 times yearly for cleaning.