Grubauer kept the game tied when he lunged across the crease to make a glove save against Marchand at 6:54, but Marchand gave Boston a 3-2 lead at 8:49 when he was left alone at the right post to score on a rebound.
Oleksiak tied it 3-3 at 9:47 with a wrist shot from the right circle after a feed from Morgan Geekie.
"It was a lot of fun," Bruins defenseman Connor Clifton said. "Obviously, it kind of went off the rails a little bit. We're not as used to those high-scoring games, [but] either way it was fun, it was electric, but we prevailed. We came out with two points, and that's what you want."
Bergeron put Boston back in front 4-3 with a short-handed goal at 17:51, moments after he stole the puck from Dunn at the Bruins blue line.