These pesky flies are considered "nuisance" pests in our homes in winter. In large numbers however, the larvae can cause significant root damage. They could have entered your home with outdoor plants that have been brought inside for the winter.
These flies will never be 100% eradicated but some control is possible.
First, hold back on the watering. Fungus gnats love wet soil! Let the top one to two inches of the potting medium dry out between waterings. That will decrease the survival of the eggs and hatched larvae. And your pots will not become a fun place to lay eggs.
Second, it is always a good idea to pick up the dead leaves and blossoms of the plants on top of the soil. No more hiding places!
Third, you have several options for more aggressive control. These insects are attracted to those yellow "sticky traps" which may slow down the egg laying females. They are available at garden centers, nurseries, and Amazon.com. You can make your own traps with yellow construction paper and Tanglefoot®
There is a parasitic nematode (microscopic roundworms which infect the larvae in an unspeakable way, causing death).which provides a long-term control and might be more appropriate for large commercial greenhouses. Home Depot® has "Fungus Gnat Control Nematodes".
I have found that the larvae are very effectively stopped by a product containing Bacillus thuringiensis subsp. israelensis (Bti). If you are starting seeds, the young roots are particularly vulnerable to the chewing larvae. Products containing this strain of Bti are available at garden centers, nurseries, and at Amazon.com. This is a very safe biological control method. Make sure you are purchasing the Bti israelensis listed as the active ingredient. Products on the market are; Gnatrol®, Gardens Alive Knock Out Gnats®, Bonide Mosquito Beater WSP®. Before using any of these products, be sure to carefully read and follow the label instructions. The granules are mixed with water and the plants are then drenched. Bti only works on the larvae of the gnats so several applications over a few weeks should do the trick to get rid of the flies!
For more information on this problem, go to the following on line sites:
University of California, "Pest Notes" Publication 7448
Missouri Botanical Garden Gardening Help "Bacillus thuringiensis..."