Darren Machon, 39, of Maesteg, had denied burgling a house in Park Street, Bridgend, in February.
But a witness spotted his "distinctive" boxer shorts after she saw him bent over while rummaging through cupboards, a statement from South Wales Police said.
He was jailed for 34 months on Tuesday after a trial at Cardiff Crown Court.
Machon was arrested for the burglary while he was in police custody for a separate offence, the police statement said.
As he was getting changed in his cell, an officer noticed his underwear, which had pictures of hot dogs and doughnuts, matched those described by the witness of a burglary earlier that day.
Det Con Darren Bowen said: "The witness in this case and also the officer who recognised the underpants also deserve credit as it was their vigilance and attention to detail which no doubt ensured that Darren Machon was linked to the burglary.
"He is a prolific criminal who will spend a number of years behind bars where he belongs - no doubt he'll spend a few of those years thinking about how he should have put his lucky pants on that day."
Machon was also convicted of dangerous driving and disqualified from driving for 41 months.

Dr Alan Parker, a senior lecturer at Cardiff University, will lead a team to examine and alter the Ad5 virus.
In its original form it can can cause airways infections and is usually spread through coughing and sneezing.
But Dr Parker will use new technology to see if it can be genetically modified to destroy cancer cells.
Ovarian cancer is the sixth most-common cancer among women in the UK, with around 7,400 women diagnosed each year and around 4,100 women dying from it annually.
"Ovarian cancer is often diagnosed at an advanced stage and five-year survival has remained stubbornly unchanged, at around 40%, for almost 25 years," Dr Parker said.
"Using viruses as a way to treat cancer is becoming more common and we're already seeing that some are showing great promise.
"People often think viruses are bad. However, they can actually be 'trained' to be an effective cancer treatment."
He said he often compares the complex research to the children's film How to Train Your Dragon.
"At the beginning of the film the dragon comes across as being destructive and deadly, but one of the characters then trains the dragon to be a force for great good," Dr Parker added.
"It's very similar to viruses. The viruses we use in their original form can cause a cough or cold.
"We want to understand how the virus infects cells so we can engineer or 'train' the virus to be a force for good by identifying and killing cancer cells."
The research is estimated to take between five and 10 years to complete and, if successful, it is hoped it could also treat other forms of the disease including breast, prostate and pancreatic cancers.
Ruth Amies, Cancer Research UK spokeswoman for Wales, said: "We hope this research will improve our understanding of ovarian cancer and help lead to the development of new treatments in the future, which could ultimately improve survival for those diagnosed with the disease."
A burglar has been jailed after his "novelty" underwear was held up in court and used as evidence against him.
[NEXT_CONCEPT]
A Cardiff scientist is to explore whether viruses can be "trained" to tackle ovarian cancer after being given a Â£250,000 Cancer Research UK grant.