The gnats that you see infesting your potted plants are most likely fungus gnats. These gnats are harmless to most plants, but sometimes the larvae do eat the leaves, such as the leaves on African violets and geraniums. The gnats also, in high numbers, can cause root rot. Fortunately, there are several methods from which to choose to get rid of the gnats (and the larvae) living in your potted plants. If one does not work, try another.
Avoid watering your plants too much. Be sure the pots have drainage holes and if not, transplant the flower to a pot with holes. In addition, allow the soil to dry out between waterings. Gnats like moist soil.
Apply sticky flytraps on top of your soil. These are available at most stores where pest control products are sold, as well as most garden centers.
Lay pieces of raw potatoes on the soil. In four days, put the potato slices in a sealed plastic bag. Throw it away outdoors in your trashcan. Gnat larvae are attracted to the potatoes, and you will be throwing out the larvae with the potato slices.
Spray a pesticide labeled as Bacillus thuringiensis (Bt). It is also sold under brand names such as Gnatrol and Knock-out Gnats. Follow label instructions to apply to your potted plant.