Moral licensing

Moral licensing or self-licensing is a cognitive bias that occurs when a person uses their prior good behavior to justify later bad behavior, often without explicitly using that logic. The effect has been demonstrated in numerous psychological studies. Evidence suggests that, though the effect is present in all sampled cultures, cultural differences explain a substantial amount of the total variation of the effect size of moral licensing. Thus, in contrast to most cognitive biases, it may be possible to actively discourage this bias in oneself.

Logical fallacy
If performed explicitly or intentionally, moral licensing acts as a fallacious attempt to shield oneself from criticism. The implicit logic operates as follows:

The logic is valid but unsound: the first premise presumes that each person has a sort of "moral balance" or "karma". This can be thought of as a "moral bank account" where one can "deposit" morality points for new moral actions and "withdraw" morality points for new immoral actions. Very few people adhere to moralities that would allow this sort of moral balancing act. This is because very few people would be comfortable with excusing (for example) murder committed by somebody who had "saved up" enough moral actions over their life.

As an example of this behavior, alt-right YouTuber No Bullshit attacked Ezra Levant for "acting Jewish" and defended this by saying that "I've called out every other race and creed on this channel". This is a red herring or a whataboutism and does not excuse bullshit for his behavior. Instead, it's a deflection from the issue at hand. The person using the moral license is attempting to shift the conversation from a discussion from "this new bad action I did" onto "am I a good person or a bad person", which are separate questions.