I was wondering how come Harry and his DA pals aren't punished for using magic in the OotP when they fight death-eaters in the department of mystery; I mean, wasn't underage magic supposed to trigger a signal that would send reinforcement to the department straight away? Is there a tread about this topic?
The problem here is that "The trace" (name of the spell put on under aged wizards) is not exactly accurate. Remember when Dobby did magic in Harry's house and he got expelled? That was because the trace is detecting magic near and under-aged student in a place where there shouldn't be any magic.
In the case of the ministry, I think it's nearly impossible to determine there is a problem there, since we're talking about the Ministry of Magic, magic in there is supposed to be everywhere.
When the members of DA performed magic in Hogwarts and also in the department of mystery, the best Ministry of Magic could determine was that certain spells were being used. Ministry cannot detect, who performed the spell.
“But how come the Ministry didn’t realize that Voldemort had done all that to Morfin?” Harry asked angrily “He was underage at the time, wasn’t he? I thought they could detect underage magic!”
“You are quite right — they can detect magic, but not the perpetrator: You will remember that you were blamed by the Ministry for the Hover Charm that was, in fact, cast by —”
“Dobby,” growled Harry; this injustice still rankled. “So if you’re underage and you do magic inside an adult witch or wizard’s house, the Ministry won’t know?”
They will certainly be unable to tell who performed the magic,” said Dumbledore, smiling slightly at the look of great indignation on Harrys face. “They rely on witch and wizard parents to enforce their offspring’s obedience while within their walls.”
“Well, that’s rubbish,” snapped Harry. “Look what happened here, look what happened to Morfin!”
“I agree,” said Dumbledore.
Harry Potter and the Half-Blood Prince, Chapter 17, A Sluggish Memory
Legally speaking, it was completely okay. The rule about underage magic is that you can not violate the international statue of secrecy, and you can not use magic outside of school, but both of these rules have exceptions for life threatening situations "OOTP". I suspect that being attacked by a large number of death eaters and potentially Voldemort himself qualifies as a life threatening situation. They weren't punished because it was legal.
The important note is - who would punish them? Trace is clearly enforced by the Ministry, however the entire staff is gone, the place deserted. Any "civilian" at all, despite the raging battle through the halls, is seen only after Voldemort and Dumbledore wreck tha Atrium.
Why weren't they punished? Nobody was paying attention to the trace at the time. Or any other ministry-related task.