There is no single answer to this question.
It appears that your risks for OCD are increased if you have a family member with OCD, if you have some of the chromosomal markers for the disorder, if you have certain abnormalities in specific parts of your brain, and if you react to intrusive thoughts, images, or impulses in such a way that you believe having these thoughts, impulses, or images can somehow make them come true.
These are probably the greatest risk factors for OCD.
Other risk factors may be experiencing a traumatic event, being highly religious, having a newborn baby in the immediate family, and the influence of culture (Japanese individuals are very concerned about offending others with their personal odor, for example).
Whatever the risk factors, just because you have a risk factor does not mean that you will develop OCD, and just because you cannot identify any risk factors does not mean that you will never have OCD. There is still much for us to learn about how we develop and maintain mental disorders.