I don't see why not, as long as it's not during flowering, should be fine. Your not dealing with fungus gnats are you? If so, drying out the soil surface during watering will make them go bye bye. Diatomacious earth also sends em to there rightful place of being fresh organic nutes.
If you can put them out on a balcony or something for a little while, you can take a fan and sprinkle DE in front of it, to completely coat everything, especially the undersides of leaves. Let it sit for a day or two, then give a good watering with either compost tea, or plain water if they don't want more Nutrients. after one or two " foliars" the DE will rinse off the tops of your leaves, and leave behind a nice protection layer underneath. You want to do this BEFORE flowering, ask me how I know!! I knew better, but couldn't help myself on that one!