The Swedes looked like they were on their way to an upset when they scored goals 20 seconds apart to take a 3-1 lead early in the second period.
But Canada responded and was spared blushes as Natalie Spooner scored two straight goals, setting up Hefford's winner.
"We really don't feel like we played our game very well today and there was a bit of a struggle throughout," Hefford said. "But sometimes games are like that. You have to grind them out and chip away, and that's how we looked at it."
Canada finished the round-robin portion of the tournament with a 3-0 record and advanced to Saturday's final against Finland (2-1), which stunned the United States 3-1.
Meghan Agosta-Marciano also scored for Canada, while Shannon Szabados made eight saves on 11 shots.
Sweden goaltender Valentina Wallner was outstanding, making 41 saves on 45 shots.
Anna Borgqvist, Jenni Asserholt and Lina Backlin scored for Sweden, which finished the tournament 0-3.
Canada brought a younger squad to the Four Nations tournament, leaving several veterans, including talismanic leading scorer Hayley Wickenhiser, off the roster for a rest.
Coach Dan Church said he welcomes the way the young squad battled through adversity.
"Coming out and struggling in the first two periods today wasn't part of our game plan," Church said. "But the response form our group was good in the third period.
"The young players have really worked hard over these last three games and that is what you want to see. Leaving some veterans at home is an opportunity for them to step up and play some more minutes and show some leadership."
Noora Raty made 58 saves and Karolina Rantamaki and Susanna Tapani scored in a 9-second span in the second period to help Finland defeat the U.S. for the first time in the history of the tournament
Megan Bozek had a power-play goal for the U.S. (1-2) in the second period to cut it to 2-1, and Tapani set up Jenni Hiirikoski's goal midway through the third period.
Canada beat Finland 3-1 on Tuesday.
The U.S. will face Sweden in the third-place game.Suggest a correction