Read the 10 tips in the article from about.com:
1. Dispose of any rotting fruits and vegetables.
First things first. As soon as you see a few fruit flies, you need to purge your produce. Anything that is beyond ripe, oozing liquid, or has been cut or broken open must go. Don’t just throw it in the garbage or compost bin, either (unless your compost bin is outdoors and located a distance from your house). Bag it up and take it outside to the trash. Then clean up any residual mess left behind.
2. Empty and clean recycling cans.
Fruit fly habitat is any place they can find something sweet or fermented, with a little moisture. Empty soda cans, wine bottles, and beer cans fit that bill perfectly. Once you’ve dumped the produce, turn your attention to the recycling bin. Take all your bottles and cans out for pickup. Then give the bin itself a thorough scrubbing to remove any residue of beer, wine, or juice.
3. Take any compost scraps outside.
If you compost your kitchen scraps, I applaud you. Everyone should compost. But if you compost your kitchen scraps and you have fruit flies buzzing about, it’s time to clean out the compost bin. Until you get your infestation under control, you’ll need to take produce scraps straight out to your outdoor compost pile. Empty any compost containers that you keep indoors, and give them a good scrubbing, too.

