There is no definitive number of years you should wait before you should replace a driveway. It will mainly depend on the materials used to build it and the condition the driveway is in. If there is no damage and the driveway is in good working order, then you may never have to do a full replacement.
Concrete and asphalt driveways are among the most durable, although sand and dirt varieties often last for years without problems as well. In most cases there is little need to entirely replace a driveway. Cracks can be filled and fill dirt can be replaced to cover holes or dips in the surface. For this reason, there is no general time line for driveway replacement because it so rarely needs to be done.
Some instances may require you to fully replace a driveway, such as when a large portion is damaged. You may also decide to move the driveway to another location by digging it up and laying a new one. Alternatively, you may decide you want to replace a driveway using a different material to enhance the look of your home or landscape. These are all personal preferences, though, and are not necessarily needed.
You may have to make regular repairs to your driveway, although this is a far cry from fully replacing it. Concrete and asphalt eventually may get cracks and stains which will need to be mended. A professional can be hired to do this, or you can do it yourself using a concrete mixture to patch the area. Just be mindful that when done incorrectly, the cracks are likely to return fairly quickly.
A driveway may need to be replaced if it was very poorly constructed. You may get clues that this is the case if the driveway cracks frequently within the first few years, despite frequent repairs. When this happens, you may have to remove the existing materials and have an entirely new driveway installed. This is relatively unlikely to occur, as most driveways can be repaired sufficiently for proper working order and visual appeal without a full replacement.