An edition of BBC1's Panorama has breached the Ofcom code after a man who was supposed to remain anonymous was identified by his friends.
The man, a gambling addict known only as Mr C, had his face obscured and he was filmed from a number of angles in an effort to stop him being recognisable, although his voice was not altered.
Ofcom said the programme fell foul of the code because his identification amounted to an infringement of his privacy.
The programme looked at the issue of gambling addiction in the UK and was screened in November.
During the investigation into Mr C's complaint, the BBC accepted that further steps could have been taken to safeguard his identity, according to Ofcom's report.
Although he had agreed to footage being included in the programme, it was on the basis of remaining anonymous, which did not happen. The regulator concluded he "did not consent to the broadcast of the relevant material as it was transmitted".
After it became clear that some contacts in his Facebook network had identified him, the BBC cancelled a repeat screening and re-edited the programme for use on iPlayer and on the Panorama website.
But Ofcom said: "The inclusion of this material in the programme as broadcast was not warranted in the circumstances."
The BBC apologised to the man for any distress he was caused.
A BBC spokeswoman said: "The Panorama team made sincere efforts to try to conceal the identity of Mr C in the making of Panorama's Gambling Nation film last year but, as Ofcom notes, they were clearly not wholly sufficient.
"The BBC repeats its apologies to Mr C for any distress caused and we note Ofcom's findings in the case."
Email pged@pressgazette.co.uk to point out mistakes, provide story tips or send in a letter for publication on our "Letters Page" blog