Symbiosis for nutritional purposes is ubiquitous. Pathogen protection is less well-known.
In unique antennal glands, female beewolf digger wasps cultivate symbiotic Streptomyces bacteria. The wasps secrete the bacteria into their larval brood cells. The larvae uptake the bacteria. When the larvae spin their cocoon, the bacteria are placed outside, where they act as protection against a wide range of potentially detrimental microbes, doing their job by producing a cocktail of at least 9 different antibiotics.
Wood cockroaches nest in the crevices of decaying tree trunks. These same crevices are home to fungi that parasitize cockroaches. The microbiome inside wood cockroaches evolved a solution: internal manufacture of an antifungal. The cockroaches insulate their homes from infestation by plastering it with their feces, which keeps the fungus at bay.
What works for a family scales up. Termites are colonial descendants of cockroaches. The earliest termites created an antifungal paste which they applied to their nests.
In evolutionary time, termites and their microbes cultivated a more mutualistic perspective with regard to fungi. Now, only a quarter of the termite species chew wood with the help of digestive microbes. The other 75% maintain fungal gardens upon which they feed.