The piyut Maoz Tzur mentions both Purim and Chanukah. Why then was it chosen to be said on Chanukah and not Purim? I've tried researching the subject and asking scholars but have not received a satisfactory answer.
It isn't known who wrote Maoz Tsur, although some scholars think that it was a 13th century German-speaking Jew named Mordekhai (sorry - only a Wikipedia reference for that one). It makes reference to several stages of Israelite history, and more than one festival:
The second stanza references the slavery in Egypt, the redemption at the time of Moses (although Moses isn't himself mentioned) and the drowning of all of the Egyptians in the sea. This corresponds to Pesach.
The third stanza speaks of the erection of a temple in Jerusalem, and of the fact that even then the Israelites did not experience peace. Due to their having worshipped foreign gods, the temple is destroyed and they are exiled, but brought back to the land of Israel in the time of Zerubbabel. (No festival in this one, but the general theme of persecution => salvation.)
The fourth stanza references the plans of Haman ("the Agagite"), the elevation of Mordekhai ("the Benjaminite") and the hanging of Haman and his sons. This corresponds to Purim.
The fifth stanza makes reference to the festival of Hanukkah: the torments of the Seleucid Greeks, the ascension of the Hasmoneans, the battle over Jerusalem and the miracle of the oil.
Finally, the sixth stanza (in which the first three words serve as an acrostic for חזק) speaks of the messianic era. In doing so, it makes reference to God bringing back "the seven shepherds", which is a reference to Micah 5:4, but also a none-too-subtle allusion to the seven shepherds in Sukkah 52b, who are Seth, Enoch, Methusaleh, Abraham, Jacob, Moses and David. In the Zohar (III:103a-104a), these are the seven visitors on the nights of Sukkot (the ushpizin). Whether the author of this text knew the Zohar or not, it's not unreasonable to suppose that this is a subtle reference to that particular festival too.
So, with references to Pesach, Hanukkah, Purim and Sukkot, why do we sing this on Hanukkah in particular? If there is an historical reason, I do not know it, and I am tempted to point out that if we were to sing it on Purim or Sukkot instead, we'd still be asking this question. (In other words, it may have no greater significance as a Hanukkah song than, say, Chad Gadya has as a Pesach song.)
But that said, consider the first stanza. There, the text explicitly mentions the dedication of the altar (חנכת המזבח), which gives us two references to Hanukkah instead of only one. Since the story of Hanukkah constitutes the latest event spoken of explicitly within the poem (notwithstanding the veiled allusion to crusaders in the final verse), and since it serves as a frame for this text, being mentioned both at its beginning and just before its end, it is therefore also able to function as the time at which the poem itself is set.