“‘I welcome the opportunity to uphold our finest Wizarding traditions and values—’ Like committing murder and cutting off people’s ears, I suppose! Snape, headmaster! Snape in Dumbledore’s study—Merlin’s pants!”
-- Hermione Granger (DH12)
“Merlin’s Pants” is a mild and slightly naughty slang exclamation, similar to the more frequently used epithet “Merlin’s Beard“.
Appearances
In the his room in the Burrow, before Bill and Fleur’s wedding and while she is packing, Ron asks Hermione:
“How in the name of Merlin’s pants have you managed to get your hands on those Horcrux books?” (DH6)
Hermione says this when she realises that the portrait of Phineas Nigellus Black at Number Twelve Grimmauld Place might be reporting their conversations back to Headmaster Snape at Hogwarts, and she runs out of the room. Ron then turns to Harry:
“‘Merlin’s pants?'” repeated Ron, looking amused. “She must be upset.” (DH12)
Ron’s reply when she returns to the room is similar but more explicit:
“And what in the name of Merlin’s most baggy Y-fronts was that about?” (DH12)
Commentary
Notes
For Americans: in British English, "pants" means "underpants", not "trousers".