In The Outsiders, a “heater” is a gun and Dally has one because of the conflict between the Greasers and the Socs that has escalated since Johnny killed Bob. He wants to have a gun so that he can at least bluff his way out of trouble.
When you are reading and you come across words you don’t know, you can at least guess at their meanings through looking at context. We first see the word “heater” on p. 29, where Two-Bit, Johnny, and Ponyboy are talking to Marcia and Cherry. Two-Bit is talking about what kinds of fights are and are not rough. He says fair fights aren’t rough and then he goes on to say
Blades are rough. So are chains and heaters and pool sticks and rumbles. Skin fighting isn't rough.
From this, we can see that heaters are some sort of weapon.
Later on, we find out for sure that a heater is a gun. This is on p. 140, right before the rumble. Ponyboy is thinking to himself about how the gangs tend to fight with anything they can find. He thinks about the various weapons they use, including
sometimes even heaters. I mean guns. I have a kind of lousy vocabulary, too, even if I am educated.
From this, we get clear proof that a heater is a gun.
Dally has a gun because of how the Socs are out to get the Greasers after Johnny killed Bob. At the end of Chapter 5 (p. 83), Dally has come out to where Johnny and Ponyboy are hiding and has driven them to a Dairy Queen. He says he has been carrying a heater. He says
The Socs and us are having all-out warfare all over the city. That kid you killed had plenty of friends and all over town it's Soc against grease. We can't walk alone at all. I started carryin' a heater...
He goes on to say that he carries it as a bluff because it isn’t loaded. Incidentally, this is foreshadowing a major event involving Dally and his gun toward the end of the book.
So, a heater is a gun and Dally is carrying one so he can bluff his way out of trouble that might arise because the Socs are looking for revenge for Bob’s death.