Answer: If you have houseplants, the pests are probably fungus gnats. Fungus gnats breed in moist potting soil, so you can break the breeding cycle by allowing the surface of the soil to dry out. If you have plants that need moist soil simply place a quick draining and fast drying layer of gravel or sand on top of the potting soil. You have to be a little patient with this method because you have to wait through the next generation's maturation before they are gone for good. In other words, once the generation now already in the soil become adults and die off without being able to reproduce, there should be no more gnats. Another method is to use a product called Gnatrol as a soil drench, another is to use an insecticidal soap as a soil drench. Of course, always follow the label instructions carefully.
If you do not have houseplants, the pests are probably vinegar flies. Sometimes they are transported inside as eggs on fruit or vegetables or they may fly indoors because they are attracted to the odor of ripening fruit. You find them near the kitchen and bathroom drains because they are looking for a water source. You can trap them by setting a glass or jar on the counter with an inch of vinegar (or wine) in the bottom. They are attracted to the odor of the vinegar or wine and will fly in and usually drown. I use a bottle with a narrow opening just to make sure they can get in but have trouble flying out. There are commercial sprays on the market if you'd rather go that route.
I hope this helps!
Q&A Library Searching Tips