If they are fungus gnats you can buy BTi (bacillus thuringiensis israelensis - it is a bacteria that also kills mosquitoes) to add to the soil when watering [e.g. "mosquito bits" on Amazon]. This will kill the larvae in the soil. Must be the "israelensis" subspecies to work.
You can also buy yellow sticky traps (Amazon) to kill the adults (bacteria only works on larval stages and you need to kill adults or they will breed elsewhere). Apparently, the flies are attracted to the color yellow (I am doubtful of this).
Some people also put sand on their plants so the flies cannot access the soil to breed (but this may affect your watering of the plants - but you should be watering from below to stop the top-layer of soil getting wet anyhow; also remove all excess water when the plant has had a drink or add in BTi to all excess water in the plant saucer). Or you can add a layer of diatomaceous earth (Amazon) to the top of your soil.
You can tell they are fungus gnats as they will fly to you and get right in your face sometimes as they are attracted to the CO2 you breathe out. They also breed in sink drains so you may want to clean those with bleach.
You will want to treat every plant (BTi) and drain (bleach) in the house simultaneously, a couple times a week, otherwise you will just be playing whack-a-mole with the gnats.