A New Hampshire man was sentenced Wednesday in Hillsborough County Superior Court in Nashua to 52 years to life in prison for the 2011 murder of an off-duty paramedic. Matthew Packer, who prosecutors said was 19 at the time of the murder, pleaded guilty to second-degree murder July 26 for stabbing Paul Frontiero the night of Oct. 9, 2011, Agati said. The prosecutor said Packer attacked Frontiero’s roommates with a knife outside their Nashua home after someone yelled “Captain Crunch’’ while Packer was riding in a passing car. Agati said the phrase apparently inspired the attack, although it is unknown why. Frontiero, who was inside at the time, tried to intervene, when Packer stabbed him 16 times, Agati said. Fronteiro was finishing up his training with EasCare Ambulance in Dorchester at the time, Agati said.