Mitchell Stephens led Canada with two goals and an assist, with Jansen Harkins, Deven Siederoff and Graham Knott also scoring.
Lucas Carlsson, Joel Eriksson and Carl Grundstrom scored for Sweden.
Zachary Sawchenko stopped 24 of shots for Canada, while Felix Sandstrom made 29 saves for Sweden.
Canada will face the United States in the semifinal round on Saturday. The Americans advanced with a 7-2 win over the Czech Republic.
The other semifinal will feature Finland and Switzerland. The host Swiss advanced with a shock 5-0 win over Russia, while the Finns blanked Slovakia 3-0.
Canada took an early 2-0 lead on goals from Harkins and Stephens, but Carlsson got the Swedes on the board with a power-play goal just 64 seconds after Stephens scored.
Siederoff scored with 34 second left in the first period to restore Canada's two-goal lead.
The Swedes came back again with Eriksson's goal at 2:51 of the second, but Stephens scored his second of the game to put Canada up 4-2 after 20 minutes.
Grundstrom and Knott traded goals 22 seconds apart in the third period to finish the scoring.
Canada's Mathew Barzal had two assists in the game to give him 12 points, tied with Auston Matthews of the U.S. for the tournament lead.Suggest a correction