Pietrangelo beat goalie Leonardo Genoni with a wrist shot to give Canada its third win in three matches. The United States faces Sweden on Wednesday.
"This is obviously one of the big ones, it's pretty special," Pietrangelo said. "We have a lot of young guys who play the world championship for the first time. You realize how good every team is. It's not a bad thing for us to face adversity."
"It's always tough (against Switzerland)," Canada captain Rick Nash said. "It was tough at the Olympics and at the world championship before."
Raphael Diaz gave Switzerland the lead when he surprised goalie James Reimer with an angled shot from the left to make it 1-0 in the first period.
But Jordan Eberle scored his third goal of the tournament to tie it midway through the second, and John Tavares made it 2-1 with 3:09 remaining in the second period.
Felicien Du Bois tied the game again in the third for Switzerland. Travis Zajac of the New Jersey Devils added two assists for Canada.
"For us this was the type of competition tonight that we need to get better in the tournament," Canada coach Ken Hitchcock said. "This was just a great hockey game. The second period was the best period we played in the tournament."
Switzerland stunned Canada 4-1 at last year's worlds, just after the Vancouver Olympics where eventual champion Canada beat Switzerland after a penalty shootout.
Reimer stopped 30 shots on Tuesday while Canada outshot Switzerland 61-33.
"Canada played a hard game. They deserved to win," Switzerland coach Sean Simpson said.
In other games, Alexei Morozov scored in the third period to lead Russia to a 4-3 win over host Slovakia in Group A. Ilya Nikulin had two goals and Alexander Radulov also scored for Russia. Miroslav Satan, Marian Gaborik and Ladislav Nagy scored for Slovakia.
In Bratislava, Germany rallied from a two-goal deficit to beat Slovenia 3-2 after a penalty shootout. Felix Schutz tied it for Germany at 5:32 of the third period to force overtime. In the shootout, Frank Hordler got the winning goal.
Germany advanced to the second round from Group A. Slovenia and Belarus will play a relegation round with the bottom teams from other groups.
France secured a place in the second round by beating Belarus 2-1 in overtime in Group B for its first tournament victory.