A recent issue of the Journal of Experimental Biology was completely dedicated to these parasites, which turn their hosts into zombies.
This is usually controlled by special biochemistry. The parasites release chemicals or manipulate the genes of their host, changing their behaviors. Most them them do this by changing the brain's chemicals, or by inducing "sickness behaviors" by messing with the host's immune system.
"The fact that parasites can so efficiently alter host behaviour is fascinating," guest editor of the journal, Michael Dickinson, from the University of Washington, said in an article in the issue. "There is something horrifying and wondrous about a tiny 'implant' being able to control such a large animal machine."