Exposure and response prevention (ERP) therapy is an effective way to treat obsessive-compulsive disorder (OCD). With ERP, you repeatedly expose yourself to an obsession, such as something you fear is contaminated. Then you deny yourself the ritual compulsive act. In this case, the act would be washing your hands.
ERP helps break the link between your obsessive thoughts and compulsive rituals. You repeat this process every day for several weeks or months. You keep doing it until your anxiety is reduced and you do not feel the need to perform the compulsive behavior in response to the obsessive thought.