Were the Unforgivable Curses legalized during the Battle of Hogwarts or was it legalized when the Ministry of Magic fell against Voldemort?
They were never legalised.
What changed in the era that Voldemort was in charge of the Ministry (through his puppet, Pius Thicknesse) was that the law was not properly enforced. The Unforgivable Curses were still illegal but the Ministry simply turned a blind eye.
“What you’ve got to realize, Harry, is that the Death Eaters have got the full might of the Ministry on their side now,” said Lupin. “They’ve got the power to perform brutal spells without fear of identification or arrest."
(Deathly Hallows, Chapter 11, The Bribe).
Depends on what you mean by "legal." Keep in mind that Voldemort was the de facto Minister of Magic towards the end of the series because the government was being run by his puppets. I can't remember if they were ever officially legalized, but Voldemort wasn't officially running the government either.
Towards the end of the book, Dark magic (including unforgivable curses) was explicitly encouraged at Hogwarts, and the Cruciatus Curse was routinely and openly used as a punishment.
Note that Order members used unforgivable curses too:
Harry Potter used the Imperius Curse to get into Gringott's and steal the Horcrux from Bellatrix Lestrange's vault and used the Cruciatus Curse on a Death Eater in revenge for spiting in McGonagall's face. McGonagall then used the Imperius Curse to force the Death Eater to stay out of the ensuing fight.