Most comets travel in highly elliptical orbits around the Sun with orbital periods (time between returns) ranging from just over three years to millions of years. Some comets, called "periodic comets", return near the Sun every few years, and travel no further from the Sun than the orbit of Jupiter. Other comets have periods of several millions of years with orbits that take them far beyond the orbit of Pluto.
Comets travel in regular orbits, their motions dominated by the gravity of the sun and the major planets, but other forces can come into play. Solar radiation causes ice to evaporate on the sunward side of the nucleus. Molecules released by the evaporation stream away from the comet and generate a jet-type reaction that pushes the comet away from the Sun and slows it down. If the nucleus is rotating, the force may be in another direction and cause it to speed up.
More about comet orbits:
Where Do Comets Come From?
The Oort Cloud
It is thought that most comets originate in a vast cloud of ice and dust that surrounds the solar system. The Oort Cloud, as it is called, extends several thousand times farther from the Sun than Pluto, the outermost planet. A star passing near the solar system may have disturbed the motions of some comets in the Oort Cloud, sending them into the solar system. Results from the Stardust mission indicate that some comet materials originated at very high temperatures, suggesting they formed near the Sun and were later transported to colder regions.