To avoid a smart-alecky answer like, "when your roof is leaking", let's break it down a little.
When making a decision about reroofing, there are a number of other factors that come into play, like extreme heat, especially in the southern part of the country. The amount of foot traffic on your roof is also a factor. That can cause the shingle granules to come off and shorten the life of the roof.
If there has been storm damage to your roof, the insurance company will usually pay to have it replaced. This is where it pays to have a contractor who has experience working with insurance companies. Roofing companies will almost always offer a free inspection for storm damage. (More on that in a different post)
Dirty shingles does not necessarily mean the roof needs to be replaced. Sometimes algae can stain the roof without causing structural damage to the shingle.
A big factor is the number and type of roof penetrations. Anything that breaks the plane of the roof is a potential trouble spot, such as plumbing stacks, chimneys, skylights, etc. That is most often where the roof will leak, and that does not necessarily mean the roof needs to be replaced. It might be as simple as using some caulk or re-flashing the area causing the problem, in which case a handyman might be a better option, as roofers generally do not want smaller repair projects.