Under which Canon law?
Canon 751: Heresy is the obstinate denial or obstinate doubt after the reception of baptism of some truth which is to be believed by divine and Catholic faith; apostasy is the total repudiation of the Christian faith; schism is the refusal of submission to the Supreme Pontiff or of communion with the members of the Church subject to him.
Canon 1364 §1: an apostate from the faith, a heretic, or a schismatic incurs a latae sententiae excommunication.
The phrase latae sententiae means a judgment or sentence which is 'wide' (latae) or widely applied; it refers to a type of excommunication which is automatic. Such a sentence of excommunication is incurred by the very commission of the offense, (CCC 2272) and does not require the future particular judgment of a case by competent authority.
Apostasy, heresy, and schism are all offences which incur a sentence of excommunication automatically. Heresy is the obstinate denial of any truth of the Catholic faith, on a matter of faith or morals, which has been definitively taught by the Magisterium.