The major restriction to the carry over enforcement is a change of possession.
Generally speaking, if there is no change of possession between the foul by the non-scoring team and the scoring team scoring, the score can be accepted and the penalty enforced on the try/kickoff.
In your scenario with no change of possession, this is moot -- foul by B can be enforced on the try or kickoff.
If there is a change of possession, the recovering team must decline all fouls prior to the change of possession in order to retain possession of the ball (and therefore the score). If the foul occurs AFTER the change of possession, the recovering team does not need to decline this foul to retain possession.
The extra bits in the rule cover USC/non-player fouls which are live-ball enforced as dead-ball. Since they're enforced from the succeeding spot, regardless of change of possession, the score counts and they get enforced on the try/kickoff.