While fungus gnats are not generally a serious means for concern, there is truly nothing more annoying in the houseplant world. Most fungus gnats are not great fliers, generally found running in and on the soil and planters of houseplants, but those that take to the sky are irritating to the people around, flying in to their faces, eyes and noses.

Fungus gnats can live in and on the soil of your plants, feeding on fungus  and decomposing matter in the soil.  Again, they are typically harmless to your plants, but can be a sign of a more serious issue.  Generally speaking, fungus gnats stick to eating the fungi and decomposing matter found in the soil.  If you are experiencing more than a couple, it can be a sign of overwatering, leading to rotting roots.  If the roots of your plants begin to rot and decompose, they become fair game to fungus gnats.
Additionally, seedlings and very young plants can succumb to fungus gnats, as they do not have a very strong root system yet.

Because fungus gnats eat fungi and decomposing matter, there are 2 effective ways to treat the soil, to kill off the fungi, and the eggs/larvae of the fungus gnats. 
The first would be with a traditional insecticidal soap.  These can generally be purchased at a nursery, and are a ready to use treatment generally found effective against fungus gnats and other houseplant pests.  

Another way, and the way we suggest treating the soil, is to combine Hydrogen Peroxide and water and do a full soil flush.  Mixing 1/3 Hydrogen Peroxide (3%) with 2/3 water, thoroughly water your plants as you normally would.
It is usually best to allow your plants to dry out as much as you can without negatively effecting them, first, before doing this soil flush.

Other natural ways to treat fungus gnat infestations include the use of nematodes or by mixing diatomaceous earth or powdered cinnamon in to your soil.  To trap and kill off adult fungus gnats, the use of sticky traps, or a cup of soapy water near your plant collection has proven to be effective.