Ummmm, if you look in Gandalfs staff, you see entwined wood. There you can see his pipe fit in it. Thus he put his pipe in the staff when he wasn't using it. And I know your thinking "But Sauramon took his staff in the tower" Yes, and if you look, its not the same staff...
There are a lot of factors contributing to this illusion. First of all, the camera remains on Gandalf's face a lot of the time, so when his pipe is not in his mouth it seems to disappear. There are several shots of him holding the reins with both hands and his pipe not in his mouth, but in one of these (when Frodo says "I'm glad you're back" and he says "So am I") you can see it in his lap. Not only that, but remember this ride through the Shire is supposed to take longer than just what we see on the screen. Jackson is trying to show us all of this wide and beautiful land. I think we're allowed to assume Gandalf puts his pipe down once in a while. ^_^
At first it seems like you just can't see it, but in one scene, he doesn't have the pipe in his mouth and you can see that both his hands are on rein. The pipe is really gone.
In the extended versions commentary of the cast, Sir Ian McKellen (who plays Gandalf) says that to please the viewers who disapprove of smoking, they made it look like Gandalf was trying to give up smoking and so as to do this he was chewing toffees, but Peter Jackson decided this didn't look quite right but still some of the scenes where he hasn't got his pipe are still in the movie