The answer to 'when to replace electrical wiring' is that you should consider replacing your home's electrical wiring if it is more than 20-30 years old, shows signs of damage or wear, or cannot safely handle your home's current electrical needs. Older wiring made with materials like knob-and-tube or aluminum can become a fire hazard over time, and may not be able to support modern electrical loads.
Signs that it's time to replace your home's wiring include flickering lights, frequently tripped circuit breakers, outlets that feel warm to the touch, and visible damage to wires or outlets. If you notice any of these issues, it's best to have a licensed electrician inspect your home's wiring and provide recommendations on whether replacement is needed.