Today, ointments come in sterile pots and tubes, the active pharmaceutical ingredient mixed with an oily carrying agent. These are unattractive to insects, and may even contain other chemicals to kill micro-organisms, bacteria and fungi.
The expression ‘a fly in the ointment’, meaning a small thing that ruins all, is likely from the Bible, a time when ointments would have been brewed from all manner of natural unctions including tallow (rendered animal fat), vegetable oils and beeswax.
Unlike inert modern synthetic bases, these would have had a ripe aroma from the start, attracting plenty of curious insects (all referred to then as 'flies').
Animal fat ointments would entice blowflies and tiny carrion beetles, which would mistake the medication for the putrescent stage of carrion decay. Plant concoctions could resemble fermenting sap, crushed leaves or decaying fruit, bringing in houseflies, fruitflies, fungus gnats and even hoverflies and bark beetles. Beeswax, and the heavy complex scent of the hive, would be a major draw to wax moths, wasps, hornets and bees.