Heatran is one of the most versatile pokemon in OU. It has a plethora of sets it can run, all of which are complemented by an amazing defensive typing and ability.
Choice Scarf
Heatran with Choice Scarf
Flash Fire
Timid 252 Spatk/252 Speed/4 SpDef
~Fire Blast
~Flash Cannon
~Earth Power
~Hidden Power Ice/Stone Edge
ScarfTran is a nice lure for pokemon that normally love revenge killing it, such as Mega Mawile and non-scarfed Landorus-Therian. Fire blast is a consistently strong STAB attack, which is why it's preferred over Overheat. Flash Cannon is also good STAB that hits the plethora of fairies in the tier hard. Earth Power and Hidden POwer Ice are coverage moves that hit a lot of pokemon in the tier hard, such as Lando-T, Zygarde, and Toxapex. As an alternative over Hidden Power Ice, you can also run Stone Edge to hit Volcarona and Mega Charizard Y.
Bulky Heatran
Heatran with Leftovers
Flash Fire
Calm 248 HP/220 SpDefense/40 Speed
~Lava Plume
~Toxic
~Taunt
~Stealth Rocks
Heatran's defensive typing gives it plenty of nice resistances to work with. This heatran set is designed to take advantage of those resistances to set up rocks, status multiple opposing pokemon, and potentially shut down some more passive mons as well. 248 ev's go into HP for bulk. The 40 speed is used to outspeed neutral nautred mega mawile, which otherwise could knock off heatran's leftovers.
Z-Heatran
Heatran with Grassium Z or Groundium Z
Flash Fire
Timid 252 SpAtk/252 Speed/4 SpDef
~Lava Plume
~Earth Power
~Taunt
~Stealth Rocks/Solarbeam
This set functions as somewhat of a combination of the previous two. Lava Plume is STAB of choice because of its decent power and solid burn chance. Earth Power is secondary coverage that hits a lot of things that Lava Plume might not. Taunt is used to shut down set up and stall pokemon, while the last slot is used for rocks because of how consistently Heatran can set them up. Groundium Z is used with earth power to hit things such as Toxapex and Volcanion that normally wall Heatran, but if those are easily covered by teammates, Grassium Z is a better option because it lures many water types that think they can come in and wall Heatran, specifically Tapu Fini.
Other Options
Magma Storm: Magma storm is a STAB option that should be considered on all of Heatran's sets. It's stronger than Lava Plume and allows Heatran to trap and deal with a lot of pokemon in the tier.
Roar: Roar is an interesting option on bulky sets that can be used to shuffle opponents around and deal passive damage using rocks.
Will-O-Wisp: Will-O-Wisp can reliably burn opponents, but Lava Plume already has a high chance and deals damage.
Choice Specs: Specs Heatran is another interesting option that doesn't see too much usage, so it may catch opponents off guard, but Heatran is just too slow to comfortably run specs.
Checks and Counters
Heatran is a very versatile pokemon that has answers for a lot of its tradition checks and counters. Water types and Pokemon with water type coverage deal with Heatran pretty easily, if Heatran isn't running Bloom Doom and don't appreciate various status moves. Fighting types and fighting type coverage are also in the same boat, but they don't appreciate burns. Mega Charizard Y can deal a lot of damage using focus blast, but has to watch out for the occasional Stone Edge. Knock Off ruins defensive Heatran sets because Heatran has no other means of recovery. The biggest answer to Heatran, however, is ground types and ground type coverage. Heatran's amazing defensive typing leaves it 4x weak to ground types so faster ground types, whether it be via scarf or just natural speed, have an advantage over Heatran. Zygarde, Garchomp, and Landorus-T all naturally outspeed, but have to watch out for burns and Hidden Power Ice. Scarf variants of the latter two and boosted variants of all three can reliably OHKO Heatran with their Ground STAB. Many fast pokemon in the tier run Earthquake and Earth Power as coverage (such as Mega Pinsir, Mega Charizard X, Mega Diancie, etc.), all of which give Heatran a hard time.