There is no simple answer for this question. But on average, it is recommended that your carpets be cleaned a minimum of once per year.
Dirt is an abrasive - like sandpaper.
Every time you step on the carpet, you grind dirt into your fibers. This cuts your carpet causing it to wear out faster. A dirty carpet will not last nearly as long as a clean carpet. Then, the longer you wait to have your carpet cleaned, the more damage you do to your carpet and the faster it wears out. According to American Furniture Manufacturers Association, you should not let your upholstery get soiled to the point of a noticeable or visible change in the color of the fabric.