When Allah (swt) has given Shaitaan the power to inject his poisonous whispers in the minds and hearts of the people, He has also guided the mankind to defend themselves from them. We find in the holy Qur’an:
“So when you intend to recite the Qur'an, seek refuge with Allah from Shaitaan, the
outcast. Verily! He has no power over those who believe and put their trust only in their Lord (Allah). His power is only over those who obey and follow him (Shaitaan), and those who join partners with Allah. (16:99-100)
“And deceive among them those whom you can with your voice... Verily! On my true
servants you would have no authority. Sufficient is your Lord as a guardian.” (17:64 65)
“And whosoever turns away (blinds himself) from the remembrance of the Most
Beneficent (Allah), We appoint for him Shaitaan to be a his intimate companion.”
And the Prophet (saw) has said:
“Abu Hurairah (ra) narrated: the Prophet (saw) said: Allah (swt) has forgiven the
Wasaawis that arise in the hearts of the people of my nation until one acts upon them or talks about them.” (Bukhari, Muslim)
“Abu Huraira (r.a.) narrated: Allah's Apostle said, "Shaitaan comes to one of you and says, ‘Who created so-and-so and so-and-so?’, till he says, ‘Who has created your Lord?’ So, when he inspires such a question, one should seek refuge with Allah at such times and give up such thoughts." (Bukhari, Muslim)
In summary then, if one lives by his faith according to the guidance provided by the Creator, seeks Allah's protection from Satan and their whispers, does not keep talking about or give in to these obsessions, and protects his mind and heart through the remembrance of Allah (swt), Allah will protect him from the evil effects of these offensive and threatening or obsessive thoughts, and will give him strength to keep them under control.
Combining these teachings of Islam with the modern treatments of OCD, while treating believing client, has been found to be extremely valuable, effective and efficient. However, it loses its effect if the therapist and/or the client does not believe in these teachings, or is unwilling to live by his faith.