If you want to keep fruit flies out of your home, the first thing you need to do is get rid of them in their harborages. Gnats will often come into the house on house plants. Before you bring a house plant into your home you should check it thoroughly for gnats.
If you find any gnats or fruit flies, take the plant outside and clean them off thoroughly. If the plant is wrapped in plastic, be sure to remove that outside also. The plastic that sometimes covers new house plants is a great place for gnats to hide.
Remove the top layer of soil in a house plant that is inhabited by gnats and replace it with sand. This will help you get the gnats at the larvae stage to stop the life cycle.
When it comes to keeping fruit flies at bay, prevention is the best policy. Do not leave rotting or decaying fruit out on counter tops. Keep all fruit in the refrigerator where gnats can’t get to it. Gnats are also attracted to wine, beer and vinegar so be sure you don’t have any open bottles of wine sitting around and keep vinegar tightly closed inside a cabinet.
You can actually use vinegar as a natural way to kill fruit flies. Leave some vinegar in an open container in the area where you are seeing the gnats. They will be drawn to it and eventually drown. Placing a paper funnel over the container with the vinegar in it will cause the fruit flies to be able to fly into the vinegar, but not get back out.
If you need to use a pesticide dust on a house plant or fruit in the home, be sure to use a botanical dust from a company such as EcoSMART. Some of these products are so safe that they are actually exempt from EPA regulation. This is what you want to use in your home around plants and edible items such as fruit.