The gnats that you see flying around your houseplant are fungus gnats. The adults roost on the plant, fly around when disturbed and lay eggs in moist soil. But it's the fungus gnat's eggs that cause the most trouble. Once they hatch, they feed on your plant's roots. Large enough numbers may stunt the plant's growth or even kill it. To get rid of fungus gnat larvae, wash the soil with diluted hydrogen peroxide. Then keep the soil dry to prevent reinfestation.
Allow the top third of the soil in the pot to dry out.
Dilute 1 part hydrogen peroxide in 4 parts water.
Pour the mixture into a watering can.
Water the houseplant until water drips out of the drainage holes in the bottom of the pot.
Cover the surface of the soil with 1/2 inch of horticultural grade sand. This readily draining medium is unappealing to fungus gnats and reduces the likelihood of further infestation.
Allow the top third of your plant's soil to dry out before watering (unless your plant requires very wet conditions to grow). By creating dry conditions between each watering, you encourage deep root growth and discourage fungus gnat infestation. Rosebud magazine advises against using a hydrogen peroxide flush on plants grown hydroponically. If your houseplant's pot does not have drainage holes, this may be contributing to the fungus gnat problem. Pots without drainage holes hold the standing water that fungus gnats need to survive and reproduce. Unless your plant requires very wet conditions to grow, switch to a pot with holes in the bottom that allow water to drain.