Fungus gnats live in the soil for part of their life cycle and may actually have come into your house via the soil. They are better at multiplying when conditions are wet, so you may want to look at your watering practices. Otherwise there have been several suggestions here recently:
1. Put sticky flypaper near the surface of the soil (you will see visible results)
2. Drench the soil with a systemic pesticide like imidacloprid (chemical control)
3. Apply a biological control like Bti (bacteria which are harmful to the gnats)
4. Change to a soilless mix
There are advantages and disadvantages to these different approaches but two things are important to keep in mind. First, all it takes is a couple of gnats to start up another infestation, so you may have to repeat the treatment at some point in the future. I like the flypaper because it's "set and forget" and works for months. Second, the gnats may be coming in with the soil you are using, so simply replacing the soil in the pots will likely not solve your gnat problem. You may want to consider a different kind of soil when you do repot to see if that helps. I personally have mostly given up on trying to prevent their entry, and instead focus on controlling the adult population.