In the Season 5 episode, New Boss, Jim wears a tuxedo after Dwight sends a notice to the rest of the office concerning the dress code. Jim is unaware that Charles Miner is coming to the Scranton Branch that day and is forced to wear the tuxedo until he leaves work.
When Charles comes to the office, Jim realizes that the prank on Dwight was not a good idea. Charles asks Jim several questions about his apparel. First of all, he asks Jim why he is wearing the clothes. Jim struggles to tell him that Dwight sent out a ridiculous notice and he was just trying to ridicule it. However, Charles doesn't buy it and watches Jim closely making sure he is not fooling around.