Here is what I wrote in a previous post...
Fungus gnats are small, grey flies about 1/4 of an inch long. They are found in moist, peat based potting soils that are rich in organic matter. Damage is done by the larvae and can be fatal to young
plants. Adults may transmit crown or root rot.
The adult female will deposit between 100 - 150 eggs on the soil surface near the
plant's stem. The eggs hatch in 4 - 6 days into white larvae with black heads. They feed on decaying organic matter and
plant tissue. They pupate into adults 3 - 4 days later.
To control, reduce the amount of watering. Allow the top layer of potting soil to dry out. most larvae are seen in the top inch of soil. If you cover the soil with a layer of sand, the adult may not lay her eggs in it.
Yellow sticky tapes can be used to trap the flying adults.
You can drench the soil with Bacillus thuringiensis (Bt) or apply preditory nematodes. Chemical controls can not be used with Bt or nematodes, but include pyrethrin or diazion. Chemicals have to be applied every few days to attack all stages of the insects development.
Good luck!