A dark episode in KHLOE KARDASHIAN’s past has come back to haunt her!

The brunette reality star was arrested for DUI in 2007 and busted again on a probation violation the following year – and that kind of behavior just won’t be tolerated by Simon Cowell, her new boss on “The X Factor.”

When Khloe joined the show, Simon gave her a bombshell ultimatum: Mess up again and you’re fired!

The ENQUIRER has learned that before he offered her the job on “The X Factor,” Simon did his homework and learned that the 28-year-old “Keeping Up with the Kardashians” star had been arrested for a DUI. And he made it clear right from the beginning that if she drank and drove again, she’d be out of a job!

“Simon has a ‘no tolerance’ policy for drinking and driving,” revealed an insider. “When Khloe joined the show, someone on the cast joked about getting a drink to welcome her, and that’s when Simon took the opportunity to lay down the law and reiterate his strict rule.

“He took Khloe aside and said, ‘If I ever see or hear that you’ve gotten behind the wheel of a car and you’ve been drinking, or, God forbid, you get another DUI, there will be no questions asked – consider yourself fired!’”

The reality star was arrested on March 4, 2007, after registering a .13 blood alcohol level, well above California’s .08 limit. She received 36 months probation and was ordered to enroll in an alcohol education program. But she didn’t complete the program and was arrested again in 2008 for violating her probation.

This isn’t the first time Khloe’s DUI has put her in front of the firing squad. In 2009, Donald Trump booted her from “Celebrity Apprentice” specifically because of the incident.

According to several sources, Simon loves Khloe’s edgy attitude, but, like Trump, he won’t stand for a boozing, out-of-control employee.

“Simon warned her from day one that she needs to give 100 percent to the ‘X Factor,’” continued the insider. “He told her, ‘This isn’t the Kardashian show. This is MY show, and it’s important to remember that it’s serious business.’

“Khloe got a bit defensive and smarted off, telling him she thought he wanted her to be the ‘wild card Kardashian’ – and that’s when he laid into her again.

“Simon said, ‘I want you to be edgy but to use some common sense. I don’t want to hear that you’re out drunk and making a fool out of yourself, me or the show!’”

Khloe, who’s married to NBA player Lamar Odom, made a shaky “X Factor” debut opposite co-host Mario Lopez on Oct. 31 and received biting criticism. wrote that she was “every bit as boring and awkward as we imagined she would be.” Another reviewer said she was “just plain awful.”

But Simon is willing to work with her as long as she stays off the booze, maintains the insider.

“Simon wouldn’t have hired Khloe if he didn’t think she could do the job,” the insider added. “He knows she has a huge fan base and will draw in viewers, but he has to protect the show. There would be a tremendous backlash if she were popped for another DUI.

“Khloe promised Simon that she’s not going to disappoint him.”