Herakles [Heracles] never engaged in combat against any Titan, neither before nor after his deification (his becoming a god).
The Olympians participated in two cosmic conflicts: Titanomakhia, the "Titans’ War"; and Gigantomakhia, the "Gigantes’ War."
The Titans’ War is supposed to have taken place tens of thousands of years before Herakles’ birth.
Herakles was, however, brought to life specifically so that he could help the Olympians defeat the Gigantes (Giants), who turned out to be the deadliest threat to them since the era of the Titans. The Gigantes’ War, during which Herakles assisted the gods, thus broke out in the hero’s lifetime, while he was still a mortal, one human generation before the Trojan War.
Here’s a basic timeline of some of the events mentioned here, using very loose dates of when they are supposed to have happened:
31,400 BC: The Titans’ War
31,300 BC: Birth of the God Hermes
31,200 BC: Imprisonment of the Titan Prometheus
1500 BC: Arabos, son of
Hermes (& ancestor of Herakles), becomes the first king of Arabia
1300 BC: Birth of Herakles
1270 BC: Herakles releases Prometheus
1260 BC: The Gigantes’ War
1250 BC: Death of Herakles
The Trojan War
The author of the Greek Mythology Link (GML) also has a chronological outline of the major events of the mythic eras. The chart from that page is displayed below, at the end of this Answer.
The Immortality and Godhood of Herakles
But before he could die, Zeus has rescued him by raising his spirit to Olympos, making him an immortal god.
The way I have always understood the story, Herakles does genuinely die, for sure. It is only after he is dead that he is raised up to Mt Olympos [Olympus] and becomes a god. This is further illustrated by somewhat of a progression of thought in ancient literature and religious cults in general but also specifically in Greek myth. In the oldest surviving written records of the final state of powerful heroes like Herakles and Akhilleus [Achilles], these characters are said by poets like Homer to simply have ended up in the Underworld after they died, just like any other mortals.
In the Odyssey, during his tour of the Underworld after the end of the Trojan War, Odysseus meets up with the shades (afterlife phantom remains, or “ghost”-versions) of, among others, both Herakles and Akhilleus, who are miserable shadows of the men they used to be. Herakles is wandering around the Underworld with his phantom bow-and-arrow set, hunting the shades of the beasts he had killed a lifetime ago. Meanwhile Akhilleus has a conversation with Odysseus in which he confesses that he would rather be the slave of a hireling in the upper world than rule over all those who have perished and descended into this dark realm. There doesn’t seem to be any indication at all here about deification or the promise of a glamorous post-mortem destination.
In later traditions, however, the story changes. Akhilleus is envisioned enjoying a blissful existence on the Islands of the Blessed, married to the Colchian princess witch Medeia, who herself appears here as an immortal minor goddess. It is in these times that Herakles is depicted as having attained immortality, and other mighty heroes and children of deities, after dying, go to live in balmy, idyllic locations like the Elysian Fields, except that Herakles rises much higher than these earthly paradises into the celestial home of the theoi athanatoi [deathless gods] themselves.
There are legends which seem partly designed to explain Herakles’ transition from a mere mortal shade in the land of the dead to a full-fledged divinity of Mt Olympos in his own right. There were different levels of deity in the various cults of Ancient Greece, in which there were divinities who were defined merely as heroes and others as hemitheoi (demigods, “half-gods”) in addition to those who were full-on theoi, “gods.” In one story, after Herakles’ suicide, his remains could not be found on his funeral pyre, so his nephew Iolaos became the first to sacrifice to the dead hero as a hemitheos (demigod).
According to Pausanias’ Description of Greece, Herakles had a son named Phaistos [Phaestus] who became king of the city of Sikyon. When Phaistos first arrived at Sikyon he found that the locals were making offerings to Herakles as a hero.
Phaistos then refused to do anything of the kind, but insisted on
sacrificing to him as to a theos. Even at the present day [
100s AD, over a thousand years after Herakles’ death] the Sikyonians, after
slaying a lamb and burning the thighs upon the altar, eat some of the
meat as part of a victim given to a theos, while the rest they offer
as to a hero.
Antagonism Against Titans
Drinking ambrosia in the company of Zeus couldn't entirely satisfy Heracles, so he continued his heroic deeds as an immortal god. Already experienced in defeating immortal beasts, he again helps the Olympians by fighting against the monstrous children the primordial gods have spawned. As a physically strong god, he was a decisive factor in ending the rule of the Titans and ensuring that the Olympian gods would rule the world.
These stories seem contradictory.
There is some confusion that has occurred here in general about the timeline, the wars and Herakles’ participation in one of them.
There actually are no ancient stories in which Herakles fights against anybody after his apotheosis (deification), apart from a mural from Athens which depicts him, as an immortal god, together with the goddess Athena and a resurrected Theseus, fighting together with the Greeks against the Persians at the Battle of Marathon in 490 BC. All of Herakles' other adventurous encounters against men, gods, giants and monstrous beasts take place while he is still alive as a mortal man. One of the main features of his story is that he earns his immortality by fighting and defeating the monsters and colossal obstacles that he encounters as a mortal. His most dramatic tasks are predetermined for him by Zeus and Hera when he is still a baby.
None of the deities that this hero ever combats are Titans. There are two different occasions on which there is an aggressive confrontation between Herakles and a Titan but both of these wind up pretty fast and quite peacefully. He once fires arrows upon Helios, the Sun, out of anger at the burning heat from this god’s light, but Helios simply laughs off the attack and even bestows a gift upon this powerful archer.
Then Pherecydes tells us that when Herakles was crossing the cosmic earth-encircling Okeanos River, its god, the Titan Okeanos (who was an ancestor of Herakles), rose up in his waves to rock the hero’s vessel in an attempt to intimidate him. Herakles threatened to shoot the Titan with his arrows, whereupon Okeanos fearfully calmed his waters. There is also the story about Herakles tricking the Titan Atlas into holding up the edge of the sky again after having taken a break from this task.
The Cosmic Wars
By my reckoning, Titanomakhia would have occurred even before the birth of Hermes, the grandson of the Titan Atlas who became the last of the Twelve Olympians. (Hermes is yet another ancestor of Herakles.) Not very long after the end of Titanomakhia, Atlas’ brother Prometheus was imprisoned by Zeus on the Caucasus Mountains on the border of Europe and Asia. The Roman writer Hyginus provides us with the chronology for this in his Fabulæ and Astronomica. In both of these works Hyginus says that, according to the Greek tragedian Aeschylus, Prometheus was kept in chains for thirty thousand years before his bonds were broken by none other than Herakles.
Even in ancient times, however, the Titans and the Gigantes, and the two separate wars that they waged against the inhabitants of Mt Olympos, were sometimes confused with one another. The writer most notorious for mixing up his Greek myths and their characters is Hyginus. He lists Iapetos, the father of Atlas and Prometheus, as a Gigantos [Giant], even though Iapetos is certainly a Titan. He makes the same slipup with the Titans Koios and Astraios. This is further complicated by the participation of some primordial Gigantes in the Titans’ War. Most of these Giant soldiers seem to have sided with Kronos against Zeus in that particular contest.
One especially clear difference between the two conflicts is that the Titans were immortal (or at least almost all of them seem to have been) while the Gigantes were not. At the end of Titanomakhia the enemies of the gods had to be incarcerated in Tartaros, the deepest part of the Underworld. Gigantomakhia, on the other hand, only ended when almost all of the Gigantes were dead.
Herakles and the Gigantes are, in a way, parallel characters. Both Herakles and the Giants are almost mightier than the gods. Gaia, the Earth, gives birth to the Gigantes in order for them to avenge the defeat of Kronos during Titanomakhia. This trips the gods out because there is a prophecy among them which declares that unless they employ the help of a mortal, they will not be able to defeat the Gigantes. Zeus takes this well in hand and contrives the means to create the strongest mortal hero of all, who, when he grows up, will be the suitably required ally against their enemy.
Thus we have the story in which Zeus disguises himself as Amphitryon, the fiancé of Herakles’ mother Alkmene, in order to consort with her and sire this hero upon her. He stretches the night in which Herakles is conceived into the length of three nights, in order to produce this strongest and toughest of men.
Meanwhile Gaia is scheming to obtain a special plant growing upon her surface. This plant is a drug with the power to make the Gigantes indestructible, even at mortal hands. So Zeus commands the heavenly lights, such as the Sun, Moon and Stars, not to shine while Gaia searches for this substance. Evidently she never finds it, because Herakles grows up, as do the Gigantes, and these huge enemies of the gods are after all slain by this mortal hero in collaboration with the Olympians.
The Precise Chronology of Gigantomakhia
Apollodorus specifies for us, in Bibliotheka 2.7.1-2, that Gigantomakhia broke out sometime after Herakles had completed his Twelve Athloi, “Labours” or “Tasks.” While sailing back to Greece from an expedition at Troy, Herakles and his army landed on the Aegean island of Kos, which was inhabited by the Meropes, and ruled by Herakles' cousin Eurypylos (a son of Poseidon). Mistaking Herakles and his men for pirates, Eurypylos and his subjects attacked them. This ended badly for the Meropes, whose king and princes were all killed while their island was laid waste. At this point the goddess Athena came to fetch Herakles from there to take him to Phlegra, in Thrace, where the Olympians were at war against the Gigantes.
After Herakles had dispensed with the Gigantes, he moved on to attack Augeias, King of the Epeians of Elis, who had broken a deal with him during the performance of one of his Twelve Athloi. Here we incidentally get a display of Herakles’ mortality and the fact that he is not all-powerful: he suffers a dramatic defeat at the hands of Augeias’ army generals, the twin brothers Eurytos and Kteatos, who are sometimes portrayed as monstrous or gigantic.
Apollodorus goes on to say that these brothers were the strongest men alive at the time. It could be that Herakles was, during this encounter, exhausted from waging cosmic battle against the Gigantes. Additionally, the Bibliotheka implies that he lost this fight because he fell sick during the attack on Elis. It may nonetheless prove that these twins were stronger than Herakles, since he was only able to kill them by treacherously waylaying them during a sacred ceasefire sometime after they had defeated him (fairly uncharacteristic behaviour for him).
Carlos Parada’s GML delineation of the timeline
See also Marc Carlson’s rendition, as well as a third alternative, from the Argyrou website.