The answer to 'when to replace pipe' is that you generally want to replace pipes when they are showing signs of significant wear and tear, such as frequent leaks, low water pressure, or discolored water. Most plumbing pipes have a lifespan of 50-100 years, depending on the material. Older pipes made of galvanized steel or cast iron are more prone to corrosion and may need to be replaced sooner, often within 20-50 years. Copper pipes can last 70-100 years, while PVC and CPVC pipes can last 50-100 years with proper installation and maintenance.
It's important to have a professional plumber inspect your home's plumbing system periodically to assess the condition of the pipes and identify any potential issues. They can recommend whether pipes should be repaired or replaced based on factors like the pipe material, age, and level of deterioration.