OCD and panic are connected because panic or anxiety often occur when a person with obsessive-compulsive disorder (OCD) cannot complete the rituals that he or she may have due to the illness. Completing certain compulsive behaviors can help to give the person a sense of control, which can prevent anxiety and panic from occurring. OCD and panic attacks are often linked; people who suffer from panic attacks will occasionally develop compulsive behaviors or OCD in order to prevent the panic from occurring.
Although which one comes first can vary, OCD and panic are nearly always linked in some way. A person might develop OCD as a result of a panic disorder, or the panic disorder as a result of OCD. A psychologist or psychiatrist can offer treatment for OCD, and there are medications available which can help to reduce anxiety and compulsive behaviors. Obsessive compulsive disorder is a mental illness that cannot be overcome through sheer willpower, and there is no shame in seeking help from a professional if the symptoms begin to affect a person's life.
Panic attacks can occur for any number of reasons. Some are brought on by a stressful or frightening event, others may be brought on by an unpleasant memory, while others can occur for seemingly no reason at all. OCD and panic are closely linked, so some people find that they can help themselves to prevent or manage panic attacks by performing compulsive, repetitious behaviors. This may or may not be a conscious decision.
For instance, someone with OCD and panic disorder might find that by flipping a light switch on and off 25 times before leaving a room, they can manage their fear and feel more in control. When they leave the house, then, they can be absolutely certain that they turned the light off, which can act as a sort of comforting mechanism if they feel anxious throughout the day. This is just one example of the way OCD can manifest itself; each person's experience may be different, and it can be more or less severe.
OCD and panic are closely linked; it is quite rare to find someone who has one without the other. Treatment plans will differ for each person, though some find that managing the panic will help with the compulsive behaviors as well. Many people find ways to manage their OCD and anxiety disorders so that they no longer negatively impact one's life and relationships.