It's wear-based.

Most brake pads these days will have a little notch (or two, or three) on the face of the pad that serves as a wear indicator. When the pad is worn down so that the little notch is no longer there, it's time for a new pad.

Absent the wear indicator, it's time for new pads when you have no more than 1/8" of pad showing. Also look for little bits of metal that may be stuck or embedded in the pads, as well as screechy noises and indications that your pads are starting to scratch your rims...