Insects play an incredibly important role in our ecosystem; that being said, there's a place for them, and that place is outdoors. Fungus gnats are not at all harmful to people or pets. However, when you begin to find them swarming plants in the house or greenhouse, it's time to get rid of the fungus gnats.
First things first, make sure fungus gnats are the real culprit; they are often confused with fruit flies. Fungus gnats look like small mosquitoes just 1/16 inch to 1/8 inch long. They are weak fliers so they tend to remain stationary, and they are often discovered by flying up when disturbed from resting on the soil surface of houseplants, compost piles, or wet bags of soil. Adult females lay up to 300 eggs in moist organic debris or potting soil. In three or four days the tiny larva appear with dark heads and whitish bodies. The larva feed on plant roots; this can stress the plants and leave openings for disease. The first symptoms of damage you'll see are wilting and general decline of plant health.
There are several preventative measures that will be helpful to get rid of fungus gnats. Since fungus gnats thrive under moist conditions, especially in decaying vegetation and fungi, let potting soil dry out between waterings. Fungus gnats often become a problem in autumn and winter when plants are brought indoors. Inspect each plant before they're brought in and be careful not to overwater the adults or larvae. Plants with poor drainage will be more susceptible to infestation, so repot plants if that is a concern. In the greenhouse, be careful to keep extra potting soil dry in a closed container. Also try to avoid standing water and hose leaks, and clean up unnecessary piles of soil or compost.
To check for and monitor the number of fungus gnats you have, you may want to purchase nontoxic, yellow sticky traps. Lay them horizontally over the rim of the pot. The adult gnats will stick to the traps. If the numbers are high, repot your plant in sterile potting mix after washing the roots thoroughly. Or try another form of pest control: Using beneficial nematodes works well and eliminates all the problems associated with chemical applications or having to repot a large number of plants. These nematodes, sold under the names of Scanmask and Nemasys, are microscopic, wormlike creatures that will destroy the fungus gnats but are not harmful to people, pets, plants, or earthworms. These products can be used whenever the soil is not frozen and will keep working for many months. If your garden center does not carry these products, you can find them in your gardening catalogs and online.