Pour boiling water and bleach over the maggots to kill them. You will need one cup of bleach per every gallon of water.
Exercise caution when pouring boiling water on flat surfaces, if the maggots are infested on a place such as a kitchen counter. The most common place for maggots to form is a garbage can, which in this case pour boiling water and bleach on them works great.
Sweep maggots into a plastic bag, seal it, and put it in your freezer for a day or two, if you do not want to pour boiling water on them. This method will also kill them.
Rinse food containers before placing them in the garbage to avoid maggots. You can double bag items such as meat, to mask the smell to keep maggots from heading to your garbage can. It's also a good idea to keep your garbage can rinsed out, so that it's clean and odor free.