Hi, you could use for instance nipagin (methylparaben). It is commonly added to artificial diet of Drosophila. The proper concentration of fungicides is dependent on insect species/artificial diet that you use.
1) Add a fungicide or a fungistatic compound to the diet. 2) keep diet in a fridge until experimental use. 3) consistently use relatively fresh diet (say not more thank 3 months). 4) surface sterilize the fridge where diet is kept before storing the diet for a few months.