pretty sure its safe untill the last few weeks, after that itll leave a gnar smell and taste due to the oily build up. Mix 10ml neem oil per litre of water, some add a few ml of dish liquid dishsoap too to help mix and suspend it in the water, id do my best not to saturate the buds with it as to not cause any bud rot or fungus's due to the moisture but yeah all rambling aside, you should be fine as long as you get the problem under control asap
As mentioned above make sure you have good ventilation and you may use oils up to 2 weeks prior to harvest... but I wouldnt do it within 3weeks just to be safe.