There are two opinions on this sort of thing ~
1. Always be honest; tell him; hope he forgives you.
2. Why upset him; it was a once-only thing & you won't do it againm, so best forget it ever happened ~ for his sake as well as yours.
What is right for you two, I don't know.
Could you keep this to yourself?
Could the friend keep it to himself?
Could anyone else find out & tell your boyfriend?
I always tend to think that honesty is the best policy, but I know that, in circumstances like these, others might disagree.
Sorry not to be able to help any more than that.
And yes, it was the wrong thing to do, but remember, nobody's perfect.