Impiety more than heresy.
Euripides' play The Bacchae centers on the story of king Pentheus who had taken a scunner to the god Dionysus and the unreasoning worship of his devotees (drinking wine, running about the woods, dancing into a frenzy, tearing apart wild animals (and - spoiler alert - eventually king Pentheus himself)). Moral of the story was, disrespecting gods can have bad consequences.
The issue came up as a matter of law as well, notably around the time of the Peloponnesian War (431–404 BC) In 431 BC, the Athenians passed the Decree of Diopeithes, which made disrespect for the gods a punishable offense, used against Anaxagoras, a philosopher friend of Pericles (Plutarch, Life of Pericles 32). He was exiled, not torn apart by worshippers in an altered state of mind.
Alcibiades was condemned to death for his alleged role in leading a band of young delinquents in mutilating the sacred herms on the eve of departing for battle. He fled town and turned traitor in an exciting twist on the story of that war, but for your purposes - it was all about disrespecting the gods.
Later on, after having lost the war, the powers that were indicted Alcibiades' old teacher Socrates on a charge of impiety, among other things. This in BC 399. (Diopeithes was not the mechanism in his case. For details see Brickhouse, Socrates on Trial (Oxford 2002)
Romans were similarly strict. DOmitian had a Vestal Virgin buried alive for consorting with a man, and he wasn't the only on.
So, yes, the ancients did take their gods seriously.