Yes, the magnetic field of the Earth has flipped several hundred times, in the past. Such an event is called a "geomagnetic reversal."
The magnetic field of the Earth is generated by the hot molten metal beneath the crust in the core and mantle. This mixture of molten metals rotate within the Earth and generate the magnetic field lines around our planet. However, this sea of molten iron is hot, dense, and chaotic and is subject to unpredictable changes. These fluctuations in the source of the magnetic field are what's causing the magnetic poles to "drift" around on the surface of the Earth (the North Pole is not at the very "top" of the world, where you would expect it to be; in fact, right now it is in Northern Canada and making its way toward Siberia in Russia). Occasionally, at seemingly random intervals, the poles of the Earth flip-flop.
The interesting thing is that geologists can map exactly when these reversals have occurred, because information about the Earth's magnetic field gets locked into rock that is pushed up from the mantle.
For more information, this article sums it all up quite nicely with great illustrations: Earth's Inconstant Magnetic Field
Thanks for the question,
(published on 12/13/11)