It depends, if it is with the aim of alleviating the anxiety that an obsession produces, yes.
The OCD works as follows:
1) Unreal or exaggerated obsession that produces great anxiety and fear
2) A compulsion/ritual to alleviate said obsession (can be mental or physical)
3) By performing the compulsion/ritual the anxiety is relieved or temporarily disappears
4) Then, the anxiety returns and therefore the obsession (go back to step 1)
It does not matter the "theme" of the obsession or the (ritual) way of relieving it. There are as many obsessions and rituals as there are people, what defines the OCD is the vicious cycle I describe above. In addition, over time, the "relief" that the ritual gives lasts less and less, returning earlier to the obsession