By far the greater number of wasps (over 500,000 species in the superfamily Chalcidoidea alone) are a special type of parasite. They are parasitoids which lay their eggs in or on the bodies of other insect species (usually the larvae such as caterpillars). 

Different species specialise in hosts from different insect orders, most often Lepidoptera, though some select beetles, flies, or bugs; the spider wasps (Pompilidae) exclusively attack spiders.

Almost every insect  pest species has at least one wasp species that preys upon it or parasitizes it. This makes wasps critically important in the natural control of pest numbers (biocontrol). Parasitic wasps are increasingly used in agricultural pest control as they themselves do little or no damage to crops. Farmers buy these parasitic wasps for insect control in their fields.

With most species, the adult parasitic wasps themselves do not get any nutrients from their prey. Much like bees, butterflies, and moths, those which do feed as adults usually get all of their nutrition from nectar. 

Parasitic wasps are extremely varied in their habits. Many lay their eggs in inert stages of their host (egg or pupa). If the prey is a caterpillar, they paralyze it by injecting it with venom through their ovipositor. Then they insert one or more eggs into the host or deposit them upon the host externally. The host remains alive until the parasitoid larvae are mature, dying later when the parasitoids pupate, or when they emerge as adults. Basically, the hosts are eaten alive.

Ichneumons 
The Ichneumonoidea is a superfamily of wasp parasitoids. It has two main families:
Ichneumonidae: this is by far the largest family. It is a very specific parasite, each species preying on only one or two prey species.
Braconidae: these are more all-round parasites which have a wide range of hosts they can parasitise.

Polydnavirus (PDV) 
Polydnaviruses are a unique group of insect viruses that have a mutualistic relationship with parasitic wasps. 

The virus protects the parasitic larva inside the host by weakening the host’s immune system. It also alters the cells of the host in ways which help the parasite. The polydnavirus, like all viruses, need a host to replicate itself. This it does in the oviducts of the female wasp. 

The relationship between these viruses and the wasp is obligatory: all individuals are ‘infected’ with the viruses; the virus has been added to the wasp’s genome.

The two main genera of polydnaviruses are the Ichnoviruses (IV) and the Bracoviruses (BV). The ichnoviruses occur in ichneumonid wasp species and bracoviruses in braconid wasps.

Host defence 
The victims of parasitoids do have defences they can use. Many try to hide from the wasps. The egg shells and cuticles of the prey are thickened to prevent the wasp from penetrating them.  When the wasp arrives, prey may drop off the plant they are on, or twist and thrash to dislodge the female. Some regurgitate onto the wasp to tangle it up. The wriggling can sometimes help by causing the wasp to miss laying the egg on the host and instead place it nearby. Wriggling of pupae can cause the wasp to lose its grip on the smooth hard pupa or get trapped in the silk strands. Some caterpillars bite wasps that approach it. Some secrete poisonous compounds that kill or drive away the parasitoid. Ants that are in a symbiotic relationship with caterpillars, aphids or scale insects defend them from attack by wasps.

Even parasitoid wasps are vulnerable to hyperparasitoid wasps. Some parasitoid wasps change the behaviour of the infected host to build a silk web around the pupa of the wasps after they emerge from its body to protect them from hyperparasitoids.

In endoparasitoids, host immune cells can encapsulate the eggs and larvae of parasitoid wasps. In aphids, a secondary endosymbiont, Buchnera aphidicola carries a latent phage. This phage makes the aphid relatively immune to their parasitoid wasps by killing many of the eggs. However, wasps counter this by laying more eggs in aphids that have the endosymbiont so that at least one of them can hatch and parasitize the aphid.

Certain caterpillars eat plants that are toxic to both themselves and the parasite to cure themselves. Drosophila melanogaster larvae also self-medicate with ethanol to treat parasitism. D. melanogaster females lay their eggs in food containing toxic amounts of alcohol if they detect parasitoid wasps nearby. Despite the alcohol slowing the growth of the flies, it protects them from the wasps.

Evolution 
Parasitoidism evolved only once in the Hymenoptera, during the Permian. It lead to a single clade, the Apocrita. Almost all parasitoid wasps are descended from this clade. 

The parasitic lifestyle has been lost several times, including among the ants, bees, and yellowjacket wasps. As a result, the order Hymenoptera has many families of parasitoids intermixed with non-parasitoid groups. The Hymenoptera, Apocrita, and Aculeata are all clades, and each has both parasitic and non-parasitic species. The parasitoid wasps do not form a clade on their own. 

The parasitoid wasps include some very large groups. Some estimates suggest the Chalcidoidea has 500,000 species, the Ichneumonidae 100,000 species, and the Braconidae up to 50,000 species.
Host insects have evolved a range of defences against parasitoid wasps, including hiding, wriggling, and camouflage markings.

A big increase of species in the Hymenoptera occurred soon after the evolution of parasitoidy in the order. The parasitoidy may have been a main cause of it. The evolution of a 'wasp waist' (a constriction in the abdomen) helped the Apocrita because it increased manoeuverability of the ovipositor (the organ used to lay eggs).

References 

Wasps
Parasitoids