Unbeaten Milan moved up to second place and level with leaders Napoli on 14 points from six games.
With his third assist of the season, Leao has contributed to 20 Serie A goals this year (10 goals, 10 assists).
Five minutes after the hosts went behind midfielder Filip Djuricic almost levelled but his fierce strike hit the bar.
Milan could have had a two-goal advantage when Charles De Ketelaere found the net with his back in the 21st but it was ruled out after a VAR review for offside in the build-up.
Sampdoria goalkeeper Emil Audero then kept out a great first-time shot by Giroud just before half-time.
Milan played a solid first half but things got complicated after the break when they were left with 10 men after losing Leao to a second yellow card for a scissor-kick which connected with the head of defender Alex Ferrari.
But 10 minutes later Milan regained the lead with Giroud's spot kick after midfielder Gonzalo Villar had handled.
"These are dirty matches," Milan midfielder Sandro Tonali told DAZN after five Sampdoria players were booked.
"But we still managed to win. If we can win in these conditions we can go a long way.
"We don't feel we are the strongest, but we feel strong."
Sampdoria applied the pressure in the dying minutes with Manolo Gabbiadini and Valerio Verre testing keeper Mike Maignan from close range as the game heated up and Sampdoria coach Marco Giampaolo was shown a red card for complaining about a foul.
"My sending off was fair because I called [the referee] a jerk but the card management was wrong," Giampaolo said.
"Beyond the fact that Milan are strong and that perhaps they would have won, I didn't like the handling of the match."
Sampdoria, who have only picked up two points so far this season, have equalled their worst start after six games of a top-flight campaign, recorded back in 2013-14.
They remain stuck in the relegation zone in 18th place.
Milan, who welcome Dinamo Zagreb in the Champions League group stage on Wednesday, host Napoli next Sunday while Sampdoria travel to Spezia on Saturday in the last weekend of Serie A action before the international break.