One day, I was checking my composition bin when I noticed that there was a large quantity of fruit flies and maggots in my composition bin. That was when I started looking online at how to get rid of them.
A main reason that your composition bin might have an opening big enough for a fruit fly to enter. If this is the case, patch the opening or switch to a new composition bin. Since maggots need a dry place to form into flies, enclosing your composition bin will kill the maggots and the worms would decompose them.
However, if you do not want an enclosed worm bin, you can try putting less compost into your composition bin, enough that the worms will be able to compost them quickly so that they will not sit out long enough to share with the maggots. You can also try burring the food deeper (I’m not sure if this is true but the majority maggots seem to be found on the surface of compost). Many herbs like lavender, basil, and rosemary repel insects, so adding herbs into your compost may be another solution (12 plants that repel unwanted insects: http://www.mnn.com/your-home/organic-farming-gardening/stories/12-plants-that-repel-unwanted-insects).
It is advisable to get rid of the maggots (and flies) as soon as possible, since they have potentials for caring viruses and diseases.
Below is another helpful website that you can use.
If you have any questions, be sure to ask them in the comment section below.