This is a live-ball foul, 15 yard penalty, and gets the 3 & 1 enforcement from the Basic Spot, in the extended period (not the next period), if accepted. That would apply to live-ball fouls by either team.
Even if Team A scored, the penalty would not be able to be "carried over" to the next period, since it would be a foul by the scoring team ("carryovers" of penalties for live-ball fouls only applies to non-scoring teams). Team B will almost always decline this penalty, end the period, and go to half-time. Team B could accept the penalty, and have the period extended; but, it would be a most rare circumstance when they would do that.
Putting the shoe on the other foot, if the foul were by Team B, Team A would almost always accept the penalty, and play another down in the extended period (but not the next period).
Yeah, in your scenario, a team gets away with a major foul. That happens, once in a while.
Robert