According to the Guidebook to the Marvel Cinematic Universe - Marvel's Thor, Odin tossed Mjolnir to Earth after Thor, so that it'd be available to him when he'd learned humility.
Declaring Thor unworthy of Asgard and his title, power, and family, Odin stripped Thor of his armor and his hammer Mjolnir, and exiled Thor to Earth. Enchanting Mjolnir to be unmovable by any who were unworthy, Odin tossed the hammer after Thor so that it would be available when Thor learned humility.
This is consistent with the comics, where it was likewise made clear that Odin sent Mjolnir to Earth, after banishing Thor there too, so that Thor could one day find it, when he'd proven himself worthy.
In Thor Vol 1 #159, it was revealed that a young Thor trespassed on the territory of the Storm Giants while hunting a birdbeast, thereby violating a treaty between the Storm Giants and the Asgardians. This resulted in a fight between him and some of the Storm Giants, which could've led to a full scale war between the two races.
Odin also judged Thor to be vain and boastful in general, and decided to strip him of his hammer and powers and banish him to Earth, in order to teach him a lesson in humility.
Odin then disguised Mjolnir as a cane and hid it in a cave in Norway, so that Thor could be guided to it, and regain his powers, when Odin deemed him worthy.
This sequence of events mirrors what we saw in the first movie, with Thor trespassing on the world of the Frost Giants against his father's orders, showing a lack of respect in the way that he spoke to his father subsequently, being stripped of his hammer and powers and banished to Earth as a consequence, but also being given the opportunity to regain Mjolnir if he proved himself worthy.
The one major difference between the comics version of the origin and the movie version is that in the comics, Odin also stripped Thor of his memories, and gave him a new body and identity as Dr. Donald Blake. Whereas in the movie, Don Blake was just an ex-boyfriend of Jane Foster, and Thor remained in his own body, fully aware of his identity as Thor.
But while the MCU writers changed that part, the two origins are otherwise similar enough that it seems clear that the movie version was loosely based on the comics version, and that Odin never intended the banishment to be permanent, in either version.