The regulator said that not enough was done to protect 13-year-old Gregory Piper, who played Ryan Pilkington in the show, The Guardian reports.
In one scene broadcast on July 17, Pilkington was headbutted by a policeman before trying to sever the officer's fingers with a bolt cutter after putting his hand in a vice.
An episode that aired on July 24 saw an officer tell Pilkington that he could end up in a young offenders institution where 16 and 17-year-olds would knock out his teeth "so you give a better blow job".
Following a single viewer complaint, Ofcom said that the BBC was guilty of a "serious lapse", adding that it was "particularly concerned about the child actor's exposure to sexualised language".
The BBC said that it was in constant dialogue with Piper's parents, but the regulator noted that "due care must be taken over the physical and emotional welfare and the dignity of people under 18".
Ofcom added that "there did not appear to be anyone who was independent and had no direct interest in the child actor's participation in the series involved in the decision making regarding his participation" - Line of Duty's creator Jed Mercurio oversaw Piper's welfare and was his main point of contact.
The BBC outlined 11 steps it had taken prior to filming and added: "We believe that overall the decisions and arrangements made minimised any risk of emotional harm during the filming process itself."
It also gave the regulator a note from Piper's mother stressing that his first acting job had been a positive experience.
However, the BBC admitted that best practice was not used in the interview scene - specifically that some of the dialogue should have been filmed with Piper not present to prevent his exposure to certain language.