It's a really difficult issue to handle. I find that keeping my mind busy with other things (school, hobbies) helps distract me from the compulsions. If I'm pleasantly busy, I'm fine. The other thing that helps is talking yourself through the urges, for example:
If you feel you need to touch a light switch three times so that the apocalypse doesn't happen (random example, feel free to laugh), walk yourself through how not touching the light switch would cause the end of the world.
1. Ask yourself "by what mechanism would this occur?" and allow your mind to wander and go crazy but take a step back and just listen to it. "okay, so I think that not touching the light switch will cause some kind of electrical impulse to travel down through the walls and initiate an earth quake and then I'll be the last person on earth and I'll have to forage for food among the ruins of urbanization..."
2. Notice gaps in logic, notice the ridiculous associations, and do this without judgement. Just notice, acknowledge and dismiss (like you're doing yoga).
3. Keep listening, standing still, waiting to decide if you're going to do the act. If you still cannot overcome the urge to do the compulsion, it's okay, allow yourself. But it might feel weaker. And every time you do it that you allow yourself to first listen to your thoughts and expose the ridiculous nature of the compulsion, it will continue to weaken until you feel that it's just not worth it anymore, you don't really believe it, and you just ignore it.
These are just ideas! They might not work for you, but I have found that they help a lot! There's no shame in giving into your OCD, especially if you take the time to hear yourself out first. Then if you still feel like doing it, do it and move on. But every time you walk yourself through your thinking, you re-program yourself just a little bit more. If you have so many urges that you don't know where to begin, you can either start with the ones that bother you most (the most time consuming or embarrassing rituals) or you can start small with things that don't matter and you would be most comfortable giving up. If you are able to, it helps to make a list of rituals and then rank them in order of how distressing they would be to give up. Then slowly start giving them up, one by one. Suddenly you'll find more hours in your day that you can fill with more rewarding activities.