Although there is some uncertainty, according to theories, comets can originate from a few different places in space depending on their orbit type. Many of the short period comets (with an orbital period of under 200 years) originate from the Kuiper Belt, a disc shaped region made up of icy bodies that spreads out between the orbits of Neptune and Pluto.
Longer period comets are thought to originate from a theoretical region called the Oort cloud. A vast sphere extending out to half way between our sun and our next nearest star, Proxima Centauri. The outer edge of the Oort cloud marks the point at which the sun’s gravitational dominance diminishes.
There are theories that many long period comets may originate from other sources (such as from other stars and solar systems). It’s thought that a large number of comets that make up the Oort cloud could indeed be extra solar and have been ‘scooped up’ by the sun’s gravitational influence as they pass through the empty vacuum of space. As the Oort cloud has never actually been ‘observed’ it is very hard for definitive proof about such origins.