CC Sabathia struck out 12 batters in six innings Wednesday, one short of his career high. That was the good news.

The bad news was everything else. Thanks to a pair of defensive mistakes by Chase Headley, Sabathia was charged with seven earned runs as the Yankees lost to the Blue Jays, 7-4, before 37,736 at Yankee Stadium.

Sabathia became the first Yankee ever to strike out at least 12 while allowing seven or more earned runs. But this one should come with an asterisk.

“I don’t think it’s seven earned runs,” a peeved Joe Girardi said. “I look at it as probably four. I know how scorekeepers do it, but there’s no reason we should have given up more than four today. We had a tough day defensively and it cost us.”

Sabathia (7-10) got plenty of swings and misses but also was hit hard as the Blue Jays scored three in the second inning and four in the fateful fifth.

In the second, Ezequiel Carrera had an RBI double, and Darwin Barney followed with a two-run double to give Toronto a 3-0 lead.

advertisement | advertise on newsday

Rookie catcher Gary Sanchez continued his home run barrage with a blast into the netting atop Monument Park leading off the bottom of the second against J.A. Happ (17-3). It was Sanchez’s third home run in two games and fifth in 48 big-league at-bats.

Starlin Castro led off the fourth with his career-high 15th home run to make it 3-2.

But the Yankees’ infield defense let down Sabathia in the fifth. Devon Travis led off with a shot to the left of shortstop Didi Gregorius, who gloved it but slipped. Gregorius threw a 17-hopper to first from his backside for what was scored a single.

Josh Donaldson followed with a slow bouncer down the third-base line. Headley threw to second in a late and unsuccessful attempt to force the speedy Travis.

It was scored a fielder’s choice. It was the wrong choice.

Yankees videos

“You’ve got to know the speed of the runner,” Girardi said.

Headley defended himself. “Honestly, I thought I made the right play,’’ he said. “He just got to second before I could get it there.”

Edwin Encarnacion hit another grounder to Headley, who stepped on third and threw to first for what should have been an easy double play. But Headley’s throw was very high for an error to put runners on first and third with one out.

Russell Martin lined an RBI single to make it 4-2. Sabathia struck out Troy Tulowitzki for the second out and appeared to be on the verge of escaping a big inning. That was until Melvin Upton Jr. belted a three-run homer to right to put the Yankees down 7-2.

Sabathia’s ERA jumped from 4.20 to 4.49. He allowed nine hits and walked one. Sabathia hadn’t had a double-digit strikeout game since 2013 and hadn’t struck out 12 since 2012. But he wasn’t thinking about that or blaming his defense.

advertisement | advertise on newsday

“I’ve got to do a better job of not giving up the three-run homer there to compound everything,” Sabathia said. “It’s a team game and we’re in it together.”

Headley atoned somewhat for his flubs with a solo home run in the sixth to make it 7-3. Aaron Judge stroked an RBI single to bring the Yankees to within 7-4 in the eighth and bring Gregorius to the plate as the potential tying run, but he struck out against Blue Jays closer Roberto Osuna.

Things sure looked rosy for the Yankees when they led Toronto 6-0 after five innings Tuesday night. Since then, the AL East leaders outscored the Yankees 19-4 in taking the last two games of the series. The Yankees are 3-9 vs. Toronto.