A high-ranking Bronx cop has been relieved of his duties over allegations he engaged in unwanted sexual behavior with a female subordinate inside his office, law enforcement sources told The Post on Thursday.

Deputy Inspector Keith Walton, commanding officer of the 49th Precinct, was stripped of his badge and gun and assigned to desk duty in another Bronx station house Wednesday, the sources said.

Walton — who was recently promoted from captain — is suspected of at least one office incident, sources said.

He was accused departmentally of sexual misconduct, sources said.

A female cop was interviewed Monday by the Internal Affairs Bureau’s “Group 1” — which investigates misconduct allegations against NYPD brass — but her role in the case is unclear, sources said.

Walton, 44, broke up with his longtime, live-in girlfriend earlier this year, and is currently embroiled in a custody battle over their 16-year-old son, sources said.

Following his September promotion to deputy inspector, Walton told the Bronx Times that “all the hard work and sacrifice really paid off,” and credited “strong support from the upper echelon of the department and the community.”

Walton — who joined the NYPD in 1996 following a stint in the Cadet Corps — also said he hoped to eventually head up the NYPD’s Community Affairs Bureau.

“I’d like to take the experiences I have had on a more local level and take that with me as I hope to help not just one area or precinct but the city as a whole,” he said.

No one answered the door at Walton’s home Thursday night.

His union chief, Captains Endowment Association president Roy Richter, declined to comment on the sex allegations against Walton, but called him “a veteran commander who excels in the community-driven focus of the department.”

The NYPD’s move against Walton follows scandalous allegations leveled against another high-ranking police official earlier this year.

In May, ex-cop Tabatha Foster publicly accused Assistant Chief Jeffrey Maddrey, commanding officer of Patrol Borough Brooklyn North, of a string of extramarital affairs, including with her.

“Somebody needs to stop chasing pregnant married girls around the department,” Foster, who retired after suffering a stroke, wrote on Facebook.

Foster later filed a $100 million notice of claim against the city, accusing Maddrey, whose wife is also a cop, of exploiting the post-traumatic stress disorder she suffers from after being sexually abused as a child.

Maddrey has told The Post that Foster’s allegations were “lies” and sources have said he defended himself during an IAB investigation.

No disciplinary action has been taken against him.

Additional reporting by CJ Sullivan