The victory gave the United States nine points in Group F. The Americans have 21 goals in five games, while the Germans have one of the best defences at the tournament.
"We were expecting (the Germans) would play well," said Stastny. "The Czechs beat us and they beat the Czechs."
In other games, Julien Sprunger scored a pair of goals and Switzerland captured a spot in the quarter-finals with a 4-1 win over Denmark.
Also advancing to the quarter-finals was Finland, which got a pair of goals from Jari Viuhkola in a 3-0 win over Italy. Marian Gaborik scored the winner to lead Slovakia past the neighbouring Czech Republic 3-2.
United States goalie John Grahame made 23 saves for the shutout, while Erik Cole assisted on all three goals.
Cole made a clean pass in front of the net to Stastny, who tipped it past Germany goalie Dimitri Patzold on the power play at 2:33 of the first period. In the second period, Cole once again fed Stastny, who poked it past Patzold at 15:26.
Stastny set up the third goal in the third period. He sent a pass from behind the net to Cole, who then passed to Lee Stempniak, who scored his third goal of the tournament at 3:31.
"His line had their best game of the tournament so far. Paul is a big part of that," U.S. coach Mike Sullivan said. "He's a guy we go to in every facet of our game, whether it be offensively or defensively, if we need someone to win a faceoff for us."
Gaborik's winner strengthened Slovakia's chances of reaching the quarters. The loss was the second straight for the Czechs, who are now tied for third in Group F with Slovakia, both with six points.
Tomas Plekanec scored first for the Czechs with a slapshot on the power play at 8:02 into the first period. But the Slovaks scored two in the second period, with goals from Pavol Demitra and Richard Kapus.
Gaborik scored his goal for the Slovaks with seven minutes to go off a feed from Miroslav Satan, batting the bouncing puck over Roman Cechmanek's head. Rostislav Klesla then got one back for the Czechs.
"Tonight was a huge difference from the last couple of games," Gaborik said, referring to Slovakia's losses to the United States and Canada. "It was a big boost for our confidence."