You can rematch Heatran after completing the Delta Episode and beating the Elite Four again. If you have already completed the Delta Episode, then you just need to beat the Elite Four. You should be able to do this any number of times, so you should be fine if you defeat a legendary Pokemon and forgot to save before you fought them.
Sources: This and knowledge.