It's important to distinguish between various types of heresy, because the "type" of heresy determines the punishment of the heretic, his guilt before God and his relationship to the Church. All formal heresy, which is when a person knows that the Catholic Church teaches X and the person chooses to deny or doubt X, is a mortal sin. If such heresy is public, then in addition to the mortal sin one is no longer a member of the Church. Material heretics dissent from what the Church teaches, but they are unaware that they're supposed to believe what the Church teaches-- such a heretic is not guilty of heresy before God, however if he is a public heretic, he is not a member of the Church.
Private heresy does not sever one's membership in the Church.