Title holders Manchester City have qualified for the Champions League last-16 along with RB Leipzig, while Barcelona face a nervous wait to confirm their place in the next round after falling 1-0 against Shakhtar Donetsk.
Leipzig will move out of the group alongside City after prevailing 2-1 at Crvena zvezda.
Barca failed to maintain their perfect record in Group H, and did not even manage the draw which would have sent them into the knockouts for the first time in three years, losing against Shakhtar thanks to Danylo Sikan's first-half header.
Porto drew level with the Spanish side at the top on nine points after beating 10-man Royal Antwerp 2-0 with goals from Evanilson and Pepe. Shakhtar are three points back in third.
Four teams are separated by three points in Group F.
City were frustrated by Young Boys goalkeeper Anthony Racioppi early on but he was sent the wrong way by Haaland's 23rd-minute penalty, and beaten again by Foden on the stroke of halftime.
Haaland smashed a superb third into the far corner in the 51st minute, before Young Boys' Sandro Lauper was sent off for the second time in three days.
"To qualify with two games to spare, that is what we wanted to do," City forward Jack Grealish told TNT Sport.
Leipzig had a dream start in Belgrade from Xavi Simons' eighth-minute drive into the top right corner and went 2-0 up through Lois Openda before an own goal from Benjamin Henrichs four minutes later made the 2020 semi-finalists sweat.
"We won in the end and have advanced. It wasn't easy. We were a little sloppy in the second half," Leipzig midfielder Emil Forsberg told streaming portal DAZN.
In Hamburg - where Shakhtar are playing their home games this season owing to the war in Ukraine - Barcelona were restricted to a handful of efforts from a distance as Sikan's looping 40th-minute header settled the tie.
"We leave this match feeling angry. Our play wasn't good enough," Barca coach Xavi Hernandez said.
"None of the things we planned came off, we're angry at ourselves. This is a clear setback."