Leafminers are insects that have a habit of feeding within leaves or needles, producing tunneling injuries. Several kinds of insects have developed this habit, including larvae of moths (Lepidoptera), beetles (Coleoptera), sawflies (Hymenoptera) and flies (Diptera). Most of these insects feed for their entire larval period within the leaf. Some will also pupate within the leaf mine, while others have larvae that cut their way out when full-grown to pupate in the soil.
Source: Colorado State University