Fungus gnats live and breed on fungus that grows on the wet soil of houseplants. Once airborne, these gnats often hover around houseplants or nearby windows. Fungus gnats do not harm houseplants, but they can be annoying to have around the house. Since adult fungus gnats only live a few days, they are easy to get rid of. However, your house infestation likely came in from a larger outdoor population, so there's no guarantee they won't be back.
Set yellow sticky traps (available at most garden centers) around your houseplants to trap any swarming adult fungus gnats.
Treat your houseplant's soil with a bacterial insecticide like Gnatrol or Knock-out. These products contain a strain of Bacillus thuringiensis, a naturally occurring soil bacteria that will kill any incubating fungus gnat larvae.
Spray your houseplant with a pyrethrin or pyrethroid insecticide like Dragnet, Pounce or Torpedo if the infestation is severe. These insecticides will kill adult fungus gnats, eggs and larvae. Follow the manufacturer's instructions for application and frequency rates.
Eliminate the fungus gnats' food source. Discourage fungus growth by avoiding high-organic-matter soil or fish-emulsion fertilizers and allowing the soil to dry out between waterings.