If they are fruit flies, as well as making sure to empty the bin regularly and trying not to leave fruit lying around for too long, the following is the best method for dealing with them.
Put about an inch or so of cider vinegar in the bottom of a wide-ish glass or jar. Add a squirt of washing-up liquid. Leave somewhere near where you've been noticing the fruit flies. Come back a few hours later to drowned fruit flies. The washing-up liquid breaks the surface tension of the vinegar so they can't just land on top and have a drink.
If it's very bad you might need to replace the vinegar/washing-up liquid every day (or even a few times a day) but if things are not too bad, a few days is fine. I start doing this as soon as I notice the first ones at the beginning of summer and continue until the weather gets cold again, usually sometime in late September or early October here.
If you have a compost heap, you might also have a lot of them around there. One way to try and minimise them is to put your fruit peels into brown paper bags before adding to the compost. By the time the paper has degraded, the flies won't have been able to hatch/will be dead.