I am always fascinated by insects that can drill through bark to lay their eggs. One such insect is a horntail wasp. I was lucky enough to catch a female in action a few weeks ago. You can see in the photo her ovipositor (a fancy term for egg depositor) is firmly sticking into the bark under her body. This is not a quick process as she inserts here ovipositor up to ¾ of an inch into the wood before laying an egg. Along with the egg she also introduces a symbiotic fungus that is necessary for larval survival.
Horntail wasp larvae feed on wood, but are not considered a pest as the female is attracted only to dead or dying trees. Insect borers in general take advantage of the tree because it cannot 'fight back' against insect attack in its weakened state. Healthy trees can drown young larvae in sap, but when a tree is dying it cannot. The tree this female was observed on has been clearly in decline for several years with lots of branch dieback and chlorotic leaves.
Female horntail wasp with ovipositor inserted into tree bark.