Is baptism necessary to go to heaven?

No, baptism does not wash away your sins or save you for heaven (I Pet 3:21). Only the death and blood of Jesus Christ can wash away your sins to make you acceptable to God. Jesus offered His blood to God Himself for all the sins of all His people (Heb 9:12-15; Eph 1:3-7). Jesus told the thief on the cross that he would be in heaven later that day, though he was never baptized.

For further study about baptism:

Catechism about baptism: Catechism.
All the Bible teaches about baptism: Baptism.