Similar to obsessions, not all repetitive behaviors or “rituals” are compulsions. You have to look at the function and the context of the behavior. For example, bedtime routines, religious practices, and learning a new skill all involve some level of repeating an activity over and over again, but are usually a positive and functional part of daily life. Behaviors depend on the context. Arranging and ordering books for eight hours a day isn’t a compulsion if the person works in a library. Similarly, you may have “compulsive” behaviors that wouldn’t fall under OCD, if you are just a stickler for details or like to have things neatly arranged. In this case, “compulsive” refers to a personality trait or something about yourself that you actually prefer or like. In most cases, individuals with OCD feel driven to engage in compulsive behavior and would rather not have to do these time consuming and many times torturous acts. In OCD, compulsive behavior is done with the intention of trying to escape or reduce anxiety or the presence of obsessions.
Some common compulsions include hand washing, cleaning, checking things (., locks on doors), repeating actions (., turning on and off switches), ordering items in a certain way, and requesting reassurance.  Compulsions are different from tics (such as touching, tapping, rubbing or blinking)  and stereotyped movements (such as head banging, body rocking or self-biting), which usually aren't as complex and aren't precipitated by obsessions.  It can sometimes be difficult to tell the difference between compulsions and complex tics.  About 10% to 40% of individuals with OCD also have a lifetime tic disorder.