It is customary to sing Shoshanas Yaakov after the reading of the Megillas Esther, both at night and by day.
While we tend to think of it as a song in its own right, Shoshanas Yaakov is actually just the conclusion of the poem Asher Heini (which, in most congregations, is recited in full after the megillah reading on Purim night). Asher Heini is a very ancient poem. R' Seligmann Baer (d.1897), in his Siddur Avodas Yisrael, describes Asher Heini as "אחד מן הפיוטים קדמוני הקדמונים" - "one of the earliest of the early (liturgical) poems." The Machzor Vitry (p.214) ascribes the poem to the Anshei Knesses HaGedolah, at the beginning of the Second Temple period. The poem is written in alphabetical order; the first sentence begins with the letter “aleph”, and each following sentence begins with the next letter in the Hebrew alphabet. The first two sentences of Shoshanas Yaakov (“Shoshanas Yaakov…” and “T’shuasam hayisa…”) complete the alphabet.
In the version of the poem found in Machzor Vitry (an important liturgical work compiled by Rabbi Simcha of Vitry, d.1105) there are two verses that follow after the completion of the alphabet. The first is a slightly different version of the familiar verse “L’hodia sh’kol…”. The second is a verse that is omitted from all modern versions (that I am aware of), "כי אתה מגן לצדיקים ומושיע לעמו ישראל בעת צרה" - "For You are the shield of the righteous and the savior of His people Israel in times of oppression."
The next section of Shoshanas Yaakov, "Arur Haman asher bikeish...", is based upon Chazal’s injunction (מס' סופרים יד:ו, ירושלמי מגילה סוף פרק ג' ועוד) that, upon concluding the reading of the megilla, we should bless the righteous and curse the wicked. This section is not included in the version of the poem found in Machzor Vitri, but is found a bit later (p.217) as part of a different liturgical poem that, to my knowledge, is no longer in use in any community.
It seems, therefore, that the version of Shoshanas Yaakov that we use today is a synthesis of the original poem of Asher Heini and another poem, otherwise almost entirely forgotten, devoted to the topic of “Arur Haman” and “Baruch Mordechai.”