Fruit flies will often occur where there are rotten or rotting fruits. This is common in kitchens, dining tables and around garbage collection/storage areas.
Sanitation is the best method of control. keep benches and surfaces clean, dispose of garbage quickly and throw away rotting or rotten fruits.
If all this fails get professional pest control help.
The best product against fruit flies is Thiamexotham that is made by Novartis. In Kenya it is marketed as Agita but it could have a different name in other countries. You can use it as a bait or surface wipe. This will attract and kill all the fruit flies on contact