The wasp slips her stinger through the roach's exoskeleton and directly into its brain. She apparently use ssensors along the sides of the stinger to guide it through the brain, a bit like a surgeon snaking his way to an appendix with a laparoscope. She continues to probe the roach's brain until she reaches one particular spot that appears to control the escape reflex. She injects a second venom that influences these neurons in such a way that the escape reflex disappears.Link
From the outside, the effect is surreal. The wasp does not paralyze the cockroach. In fact, the roach is able to lift up its front legs again and walk. But now it cannot move of its own accord. The wasp takes hold of one of the roach's antennae and leads it--in the words of Israeli scientists who study Ampulex--like a dog on a leash.
The zombie roach crawls where its master leads, which turns out to be the wasp's burrow. The roach creeps obediently into the burrow and sits there quietly, while the wasp plugs up the burrow with pebbles. Now the wasp turns to the roach once more and lays an egg on its underside. The roach does not resist. The egg hatches, and the larva chews a hole in the side of the roach. In it goes.
The larva grows inside the roach, devouring the organs of its host, for about eight days. It is then ready to weave itself a cocoon--which it makes within the roach as well. After four more weeks, the wasp grows to an adult. It breaks out of its cocoon, and out of the roach as well. Seeing a full-grown wasp crawl out of a roach suddenly makes those Alien movies look pretty derivative.