The answer to 'when to replace switch' is that switches should be replaced when they are no longer functioning properly or have become worn out over time. Switches can wear out due to frequent use, age, or exposure to environmental factors like moisture or dust. Signs that a switch needs to be replaced include flickering lights, intermittent operation, or the switch feeling loose or not making proper contact.
As a general guideline, most light switches and electrical switches will last 10-20 years with normal residential use before needing replacement. However, factors like the quality of the switch, how often it's used, and the environment it's installed in can affect its lifespan. It's a good idea to inspect switches periodically and replace them if they show signs of wear or damage.