A veteran comic — who garnered rave reviews for his brief stint on TV’s “Louie” — has gone to war against the Jersey cop he says broke up his marriage.

Jim Florentine, who appeared in the season finale of Louis C.K.’s FX sitcom, has written to the Matawan police chief and the Monmouth County Prosecutor’s Office asking that the hunky 23-year-old cop be prosecuted for public lewdness, or at least be disciplined for bad judgment, The Post has learned.

Florentine launched his letter-writing campaign after hiring private investigators to tail his then-wife.

The officer, Eric Otten, admitted to probers that he’d had sex in public with the comic’s spouse, Samantha Warner, once in her car in a tavern parking lot after their first “date” and again in Holmdel Park, according to a statement signed by the cop, a copy of which was obtained by The Post.

Otten told investigators he had met Warner at the CrossFit gym in Marlboro and that the pair started having sex “the first or second Saturday in November.’’

Their first encounter was in the parking lot of Rosey’s Bar in Marlboro, he said, according to the interview transcript.

The thrice-married Warner, 30, and Florentine, 50, divorced in March after a two-year marriage. They share joint custody of their 5-year-old son, Luke.

It was the first marriage for Florentine, who also co-hosts “That Metal Show” on VH1 and is a regular on “The Howard Stern Show.”

When asked about his letters to Monmouth County Acting Prosecutor Christopher Gramiccioni and Matawan Police Chief Jason Gallo, Florentine told The Post, “I can confirm I sent them.”

“But other than that, I want to focus on raising my son and getting on with my life,” he said.

Asked about the affair last week, Warner told The Post, “I really think that the details of any of the relationships involved really need to remain private.”

Warner, asked whether she is still dating Otten, said, “We do see each other generally.”

Dan Motley, a retired New Jersey state trooper whose firm, DCM Investigations, was hired by Florentine to trail Warner, said his client’s letter campaign “is not revenge.”

“[Florentine] has family in Absecon and Matawan near where this guy patrols,” Motley said. “He has concern about [retaliatory] motor-vehicle stops, stuff like that.”

Otten declined to comment, telling a Post reporter outside his and his parents’ house in Aberdeen, “I can’t help you.”

The Matawan police chief and Monmouth County’s prosecutor did not respond to requests for comment.

In the “Louie” episode, Florentine plays a hack comedian named Kenny who dies in a tragi-comic fashion: He slips and cracks his head while attempting to defecate in a toilet’s tank.