The actor, who has been portraying Ricky Campbell since summer 2009, confirmed the news on his Twitter page this afternoon (May 18).
Margolis told his online followers: "So I can finally say.. My final eps have been written. I will be leaving the show next month. It's been a fab 3 years but time to move on!
"Thanks to all of you lot for your kind messages about my curly twin.. Keep watching anyway!!"
He added: "It was a tough decision to leave but I want to do other things!! I've had the best 3 years of annoying my castmates! They will miss me.. :-)"
Ricky's first major storyline on Hollyoaks saw him acting as a carer for his father Martin, who suffers from MS. Fans will also remember his double act with best friend Duncan Button, who was played by Dean Aspen.
The sixth-former's final scenes are expected to air in a few months' time.