Swedish researchers from the Karolinska Institutet think the condition could be determined from when babies are in the womb.
They found children delivered by C-section or those whose mothers smoked during pregnancy were associated with a higher risk for developing OCD.
RELATED: Celebrity dads with their kids
Celeb dads with their kids
Celeb dads with their kids
LOS ANGELES, CA - APRIL 16: (L-R) Romeo Beckham, Harper Beckham and David Beckham attend the Burberry 'London in Los Angeles' event at Griffith Observatory on April 16, 2015 in Los Angeles, California. (Photo by Jeff Vespa/Getty Images for Burberry)
LONDON, ENGLAND - JULY 08: David Beckham and son Romeo Beckham attend day nine of the Wimbledon Lawn Tennis Championships at the All England Lawn Tennis and Croquet Club on July 8, 2015 in London, England. (Photo by Ian Walton/Getty Images)
NEW YORK, NY - MAY 29: Actor Will Smith and son Actor Jaden Smith attend the 'After Earth' premiere at Ziegfeld Theater on May 29, 2013 in New York City. (Photo by Jennifer Graylock/FilmMagic)
LOS ANGELES, CA - FEBRUARY 09: Ben Affleck is seen with his daughter Violet Anne Affleck on February 09, 2014 in Los Angeles, California. (Photo by GONZALO/Bauer-Griffin/GC Images)
NEW YORK, NY - JULY 17: Tom Cruise and Suri Cruise are seen leaving chelsea piers at Streets of Manhattan on July 17, 2012 in New York City. (Photo by Alo Ceballos/FilmMagic)
Actor Brad Pitt and children Pax Jolie-Pitt (L), Shiloh Jolie-Pitt (C) and Maddox Jolie-Pitt arrive for the U.S. premiere of Universal Pictures 'Unbroken,' December 15, 2014 at the Dolby Theatre in Hollywood, California. AFP PHOTO / ROBYN BECK (Photo credit should read ROBYN BECK/AFP/Getty Images)
NORTHAMPTON, ENGLAND - AUGUST 30: Brad Pitt and his son Knox Jolie-Pitt attend the MotoGP British Grand Prix race at Silverstone ahead of the release of documentary Hitting The Apex. Pitt is presenting the film, which is out in cinemas 2nd September and on DVD 7th September at Silverstone Circuit on August 30, 2015 in Northampton, England (Photo by Mike Marsland/WireImage)
LOS ANGELES, CA - NOVEMBER 18: Actor Peter Facinelli (c) and daughters Luca Bella Facinelli (r) and Lola Ray Facinelli (L) arrive at the Los Angeles Premiere 'The Hunger Games: Catching Fire' at Nokia Theatre L.A. Live on November 18, 2013 in Los Angeles, California. (Photo by Jon Kopaloff/FilmMagic)
NEW YORK, NY - OCTOBER 18: Actor Hugh Jackman and Ava Eliot Jackman are seen on scooters in Soho on October 18, 2013 in New York City. (Photo by Raymond Hall/FilmMagic)
ATLANTA, GA - JULY 21: Usher (R) and his son, Usher Raymond V, attend Usher's New Look Foundation - World Leadership Conference & Awards 2011 - Day 2 at Cobb Galleria on July 21, 2011 in Atlanta, Georgia. (Photo by Chris McKay/Getty Images for Usher's New Look Foundation)
Johnny Depp & Wife Vanessa Paradis Take Their Two Children For A Picnic In A London Park. (Photo by Antony Jones/UK Press via Getty Images)
NEW YORK, NY - MARCH 04: Jon Stewart and son Nathan Thomas Stewart attend the Cleveland Cavaliers vs New York Knicks game at Madison Square Garden on March 4, 2011 in New York City. (Photo by James Devaney/WireImage)
NASHVILLE, TN - AUGUST 15: Musician Tim McGraw, left, performs with his daughter Gracie McGraw on the 'Shotgun Rider' tour at Bridgestone Arena on August 15, 2015 in Nashville, Tennessee. (Photo by John Shearer/Getty Images for Big Machine Records)
LOS ANGELES, CA - APRIL 03: Will Ferrell and his son attend a basketball game between the Portland Trail Blazers and the Los Angeles Lakers at Staples Center on April 3, 2015 in Los Angeles, California. (Photo by Noel Vasquez/GC Images)
LOS ANGELES, CA - FEBRUARY 23: Will Ferrell and his son Axel Ferrell attend a basketball game between the Brooklyn Nets and the Los Angeles Lakers at Staples Center on February 23, 2014 in Los Angeles, California. (Photo by Noel Vasquez/GC Images)
BEVERLY HILLS, CA - OCTOBER 21: Honoree Matthew McConaughey (R) accepts the American Cinematheque Award with Vida Alves McConaughey (L) onstage at the 28th American Cinematheque Award honoring Matthew McConaughey at The Beverly Hilton Hotel on October 21, 2014 in Beverly Hills, California. (Photo by Kevin Winter/Getty Images)
LOS ANGELES, CA - JANUARY 25: Tobey Maguire and Jennifer Meyer with their children Ruby Maguire and Otis Maguire are seen on January 25, 2014 in Los Angeles, California. (Photo by Bauer-Griffin/GC Images)
LOS ANGELES, CA - MARCH 20: Actor Jack Black (C) with sons Thomas and Samuel attend the Milk + Bookies Second Annual Reading Room Sponsored By Children's Book Of The Month Club at Skirball Cultural Center on March 20, 2011 in Los Angeles, California. (Photo by Neilson Barnard/WireImage)
ASCOT, UNITED KINGDOM - MAY 31: (EMBARGOED FOR PUBLICATION IN UK NEWSPAPERS UNTIL 48 HOURS AFTER CREATE DATE AND TIME) Chris Hemsworth and daughter India Rose Hemsworth attend day 2 of the Audi Polo Challenge at Coworth Park on May 31, 2015 in Ascot, England. (Photo by Max Mumby/Indigo/Getty Images)
INGLEWOOD, CA - AUGUST 24: (L-R) Blue Ivy Carter, recording artists Jay Z and Beyonce speak onstage during the 2014 MTV Video Music Awards at The Forum on August 24, 2014 in Inglewood, California. (Photo by MTV/MTV1415/Getty Images for MTV)
Discover More Like This
BACK TO SLIDE
Other factors included children who were born early or had low birth weight.
Researchers examined data on 2.4 million kids born in Sweden. 17,305 were diagnosed with OCD at an average age of 23.
It's important to note the cause linking OCD to perinatal factors remains to be identified. Still, the study's authors say the findings are an important step to understanding the disorder.
The study was published online by JAMA Psychiatry.