OCD patients can experience some relief through cognitive behavioral therapy, particularly a form called exposure and response prevention. This entails gradually exposing the patient to the feared obsession. For instance, if the patient is obsessed with cleanliness, they are exposed to dirt for gradually increasing amounts of time. This helps the patient to learn new thought patterns and behaviors about their obsession with dirt. Although this form of therapy takes a lot of effort and practice, the reward is a much better quality of life for the patient.
The basic premise behind exposure and response prevention is that compulsion allows obsession to exist by interrupting the habituation process. The process of habituation is what causes a person to have less interest in a certain event once that person has witnessed the same event many times. For example, if your friends threw you a surprise party every day, you would eventually stop being surprised and thrilled. In the same manner, if the compulsion did not exist, the obsession would become less and less interesting until it eventually disappeared. Once a compulsion is fulfilled by an obsession, the person feels short-term relief of anxiety. The relief serves to reinforce the compulsion like a reward, and it becomes a perpetual cycle. Simply put, without compulsion, obsession would not occur and vice versa.