Ick I really, really hate these flies. They were all over our house since I re-potted our houseplants with soil from a bag that'd been open and in the garden for months. They don't bite, thankfully, and don't do any harm but fly in front of your face while you're watching TV, and they just make your house feel unclean.
So what are these pesky little blighters? They're call Sciared flies (aka fungus gnats). They're a tiny 2mm in size and thrive in potted plants where females lay up to 200 eggs at the base of the plant, and larvae stay beneath the moist soil surface feeding on dead organic matter.
The most annoying thing about these flies is that they have a year-round lifecycle with eggs hatching and becoming adults between 14-25 days depending on the temperature, so you can see how they can quickly become a big problem.
So, my recent tried and tested way of getting rid of these pests are as follows:
Remove excess water your plant may be standing in and clean around the plant pot and saucer with a damp cloth
Removing any old, dead leaves and fungal growth from the top of pots
Water plants only when required (from the top) to prevent the build up of fungal growths
Cover the surface of pots with sand (about 2cm deep), which acts as a barrier against egg laying females and the developing larva beneath
Sand was a game changer in my house. Afterwards we saw fly numbers drop and just a few days later there were none. Give this a try and let me know if it works for you.