A veteran Los Angeles cop was arrested after allegedly having sex with a 15-year-old cadet suspected of joyriding stolen patrol cars.

LAPD Police Chief Charlie Beck personally handcuffed Officer Robert Cain on Thursday, calling his actions “despicable.”

The teen had been a cadet for three months and text messages on her phone led investigators back to Cain, 31.

Their relationship took place outside the 77th Street Division station where the 10-year veteran worked.

“Obviously, this is not the police department that I want to lead,” Beck said.

Cain had been in charge of the station’s equipment room and handled checking out police gear and patrol cars.

Four cadets – including the girl involved with Cain – are accused of leading police on a wild chase around the city last week in stolen police cars.

Two of the cars crashed.

Investigators said the teens used the name of a vacationing sergeant to sign out the vehicles – as well as stun guns and radios.

Some of the cadets were decked out in homemade police uniforms and impersonated cops as they made traffic stops, Beck said.

Cain, who was charged with having unlawful sex with a minor, has no “significant history” of disciplinary actions or use-of-force complaints, the chief said.

The LAPD’s cadet program is available to 14- to 21-year-olds and gives them free training in police work. The 2,300 cadets who are enrolled can perform traffic duties and crowd control but are not sworn police officers.

With Post Wires