They aren’t commonly used, but instead are usually used for chronic, nonhealing wounds that are infected despite more conventional treatment. You can’t use just any maggot, it has to be specific species (usually blowfly larvae) and they are sterilized with radiation first (so don't try this at home kids). The larvae secrete enzymes that liquefy dead tissue and kill bacteria. This provides a painless way to debride tissue instead of using surgery.
The medical use of maggots became widespread in World War I. Wounded soldiers would get trapped in no-man’s land between the trenches and it would take several days before the lines could be advanced so that the injured man could be retrieved. The military doctors noticed the patients that had maggots in their wounds were still alive while others had usually died of infection.
By the way, medical use of leeches are also making a comeback, mostly in skin grafts and surgical re-attachment of limbs. This year the FDA approved both leeches and maggots.