The larvae of a few wasps bore or mine into trunks, twigs, or pithy stems such as roses. The larvae of the pigeon tremex, a horntail, tunnels in dead or dying wood of maples, beech and several other fruit trees and forest hardwoods.
Prune out infested wood as well as any dead and dying branches.
See also "Sawflies - Borers and Miners".