Even insects do it
It is not clear whether these effects are merely incidental to feeding, but the dietary choice is distinctly beneficial.
Scientists studying lethal parasites in insects have found convincing evidence that insects do self-medicate. Woolly bear caterpillars of the tiger moth spend the spring munching vegetation. By summer, when parasitic tachinid flies inject their eggs into unlucky caterpillars, they are plump and succulent. The fly larvae develop inside the caterpillars' abdomens, feeding off their fat reserves and eventually taking up the whole body cavity. Finally, the larvae emerge by making a hole in the cuticle wall.
When studied under laboratory conditions, most caterpillars quite understandably died from their parasites, but when the caterpillars were reared in outdoor field cages, scientists noticed that the survival rate of parasitised caterpillars was much higher. Outside, the caterpillars ate two main food plants, lupine and hemlock. While healthy caterpillars fared best when they were fed on lupine, parasitised caterpillars did better on the more poisonous hemlock. Given a choice of plants, healthy caterpillars preferred to feed on lupine and parasitised caterpillars preferred to feed on hemlock - having parasites affected the dietary choice and the change in diet improved the chances of survival.
Once again we see the importance of studying animals under natural conditions. If the scientists had continued to do all their research in the laboratory, the caterpillars would never have had the opportunity to display their self-medicating strategies.