Speaking for NCAA only. Just being accurate here. They don't "offset," but the penalties "cancel." A fine distinction, I will grant you. But a distinction by rule (10-1-5 Exception). If I am making the announcement, I say, "After the down, Unsportsmanlike Conduct, number 55 defense; Unsportsmanlike Conduct, number 78, offense. Those penalties cancel. Third down." Note that I didn't say, "Those fouls cancel." Fouls offset. Penalties cancel.
Also note that the down number is not affected by the cancelation of the penalties. When the ball became dead with no live-ball fouls, if it would next be third down, then, after the cancelation of the dead-ball foul penalties, the down will still be third down. (No automatic first down for Team B fouls when the penalties cancel.) Of course, any disqualification or ejection will still be valid and honored. Send him/them off to the sidelines (DQ), or to the dressing room (ejection).
This could apply to pre-snap fouls, too. For example, after the ball is RFP on third down, with the clock running at 6:00 (3), defensive lineman B77 beats the snap and forcibly charges into offensive guard A66 with the crown of his helmet, and then A88 grabs B77 and slams B77 to the ground in retaliation. TGT, B77, with UNR (flagrant), A88. The PENALTIES cancel, and it will still be third down. B77 is disqualified. A88 is ejected. The play clock is set to 25 seconds, and both the play clock and the game clock will start on the referee's signal.