I suffer from (pure o) OCD, so I can sympathize with how distressing certain obsessive and intrusive thoughts can be. The key I've found, is not trying to fight them when they come into your mind. No matter how provoking they're, just work on accepting them and not having an emotional reaction. This is easier said than done of course, but entirely possible. You see- when a person reacts angrily or worried about the thoughts, it sends a message to your subconscious brain that ''this is a big deal!'' and so the thought will continue appearing until they're no longer worrisome.
I'm starting to think I may have some form of OCD myself, but not certain of that. But you're right, the goal is to not have an emotional reaction to bad thoughts, and you're even more right that it's easier said than done!