He isn't really running endlessly. He is taking the shortest route towards Doflamingo every time. In the palace, he did not take any detours and barged straight into the castle, going straight for Doflamingo. Then later, when the palace was relocated, again, just jumped straight down into the city, running straight towards Doflamingo again. Remember how he originally went over the stone statue, as he thought it would be a short-cut, the same with the well. There was no instance where he just endlessly ran about.
In short, it would not make much sense to use up your stamina even before the game started. Imagine Marouane Fellaini, imagine him having an important football match in a few hours, would it make sense for him the give it all he has got and run towards to stadium to get there faster? It wouldn't, because the run is not important at all and he would not be able to last until the end of the match to his full extend. The same would happen to Luffy. Luffy is well aware of the fact that he will need every last bit of energy he has got to take down Doflamingo.
Additionally, as explained here, what happens with Gear 2, is that Luffy is drugging himself, by making his heart pump his blood around much faster. Originally it was introduced as a major drawback as it would eat away at his life, since his heart would have to pump at abnormal rates. Assuming that it is still true to some extend, it would not really make sense to shorten your life for no aparent reason. Keep in mind that at those times, nobody was in real imminent danger and there was no real need for him to get to Doflamingo asap.
On top of that, Luffy was never running alone. There was always someone slower with him (Eg: Zoro, kinemon, Violla, Law, Soldier, etc), so if he would just run off alone, he would basically leave his friends behind, unable to protect them. So by going together, he does not put pressure on his heart, is able to protect his friends and can have some fun along the way.