Yes, it is possible to be hospitalized for OCD. This can occur for several reasons.
First, it may be a way to help stabilize someone whose rituals have become so problematic that all he or she does all day long is perform rituals.
Often in these cases family members will bring someone in to a hospital because they do not know how else to get the person to stop ritualizing. This could happen because the person with OCD has reached out and asked for help that the family does not have the resources to give, or it could happen by force.
At times, parents have just picked up their children and taken them to the hospital to get help. Or people with OCD may go to the hospital on their own because they are so overwhelmed by their OCD that they do not know where to turn to for help. Most likely the first step after the person reaches the hospital is the start of an intense medicinal intervention, followed by a transfer to some type of intensive outpatient treatment once the person is stabilized on their medications and has seen some decrease in his or her ritualizing.
Second, hospitalization could occur because of a medical complication that has resulted from the ritualizing (such as skin lesions from washing excessively or muscle cramping from bending over and retying shoes hundreds of times a day), or it may occur because a person is suicidal as a result of feeling ruled by their obsessions and compulsions.
If this is the case, then the person should be stabilized in the hospital to be sure that he or she is not a danger to self, and then the person can be transferred to a less intensive level of treatment.