A gravitational field is path independent. Why does a rocket not fly in serpentine lines? in theory a gravitational field is path independent, a gravitational field is a gradient field and so conservative. why doesn't a rocket fly in serpentine lines to exit the gravitational field of the moon, as said the gravitational field of the moon is path independent and the moon has no atmosphere and so there is no aerodynamic drag?
https://en.wikipedia.org/wiki/Gradient_theorem
https://en.wikipedia.org/wiki/Conservative_vector_field#Path_independence
i know that the reason is that flying in serpentine lines would require more energy ( fuel ) however where is this surplus of energy for a serpentine line path reflected in the theories?
 A: I sometimes walk up broad stairs or slopes in a serpentine or diagonal way; the change in potential energy is the same, but the power needed is smaller. In many physics cases there is a limit on how much power can be supplied.
A rocket works by ejecting reaction mass to generate thrust: $$m\frac{dv}{dt}=-v_e \frac{dm}{dt} + F.$$ Note that without force $F$ this equation "doesn't care" when you fire your engine, the overall effect is the same increment of velocity - but if you care how fast you get to a particular point you want the high speed to show up early so most of the distance is covered at high speed.
While the force $F$ may be conservative for constant mass-objects, this may not be true for changing mass objects. If $F=GMm/r^2$ the force later can be reduced if you expel a lot of mass early when $r$ is small. Conversely, if you want to make a velocity change there is a $\Delta v/\dot{m}$ advantage in doing that when you are close to a planet (an Oberth manoeuvre). So in a sense there is a lot of "snaking around" when deciding when to fire the engines.
However, the question was about general travel from A to B. Note that if you fire your engine a bit sideways rather than steering "straight" at B then you will eventually have to fire it again to get an opposing sideways velocity so you don't miss B. That is wasted energy: you both had to spend energy to cancel the earlier firing, and you have less energy to bring you to your destination fast. 
A: What you say would be true if rockets were held up by, say, a very long string. Since real rockets don’t have such a string available they have to do something much less efficient: fight the gravitational force by pushing fuel downward. A rocket needs to exert energy just to stay in the same place, let alone move in a fancy pattern! This is why a space elevator would be so helpful; it’s essentially just a long string extending out to space.
A: Let's suppose that instead of traveling straight up, the rocket travels some distance north (and up), and then changes its direction and flies south (and up), ending up at the same elevation as in the original flight plan.  Your question is, "why does the second flight plan require more energy, since the change in the rocket's gravitational potential energy is the same in both cases"?
The answer is that to change direction, the rocket also requires an expenditure of fuel.  This comes not from energy conservation but from momentum conservation:  to change velocity from northward to southward, the rocket must eject a significant amount of mass (fuel) at high speed northward.  This ejected fuel will have a significant amount of kinetic energy due to its horizontal motion;  and this energy is effectively "wasted", since it doesn't contribute to the upward motion of the rocket.  In other words, what is conserved (roughly) is the following:
$$
(\text{chemical energy of initial fuel}) = (\text{final KE of rocket}) + (\text{final PE of rocket}) \\+ (\text{final KE of ejected fuel}) + (\text{final PE of ejected fuel})
$$
If you are giving the fuel additional kinetic energy in the horizontal direction while trying to keep the final KE and PE of the rocket the same, you'll need more initial fuel to do this.  (And then the tyranny of the rocket equation kicks in.)
A: 
In theory a gravitational field is path independent, a gravitational field is a gradient field and so conservative.

Correct.  But what this means is that the total work done by gravity is constant over the path.

why doesn't a rocket fly in serpentine lines to exit the gravitational field of the moon, as said the gravitational field of the moon is path independent and the moon has no atmosphere and so there is no aerodynamic drag?

Because the rocket is using its engines.  And the engines are not a conservative force on the rocket.  The work done by the engines on the rocket depend on the speed and direction of the rocket. 
