Hafetz Haim Halachot
Halacha 117 / 215

Hilchos Lashon Hara chapter 8, section 5 6

The prohibition of lashon hara applies only to a person who, by Torah law, is included in "your fellow" (amitecha), meaning someone who is with you in Torah and mitzvos. But about people who are known to be apikorsim (heretics), it is a mitzvah to speak against them and shame them, in front of them or not, whether about what one sees them do or what one hears about them. This is because it is written "A man shall not distress the one with him" and "Do not go like a talebearer against the one with you," and they are not included in "the one with you." And it says, "Do I not hate those who hate You, O L-rd, and I quarrel with those who rise against You" (Tehillim 139:21).

An apikoros is someone who denies the Torah and Jewish prophecy, whether the Written Torah or the Oral Torah. Even someone who says that the whole Torah is from Heaven except for one verse, or one kal vachomer (a logical inference), is also considered an apikoros.

This is only if he heard words of heresy from them himself. But if others told him, it is forbidden to rely on that to speak against them, in front of them or not. He also should not decide in his heart that it is true. For now he should only be cautious, and privately warn others not to get close to that person for now, until the matter becomes clear.

All this is about something that was just heard. But if they are known in the town as apikorsim, the rule is as if he knew it himself.