The actor directs his wife Nicole Ansari in Sinners, in which she plays a woman due to be stoned to death for having an affair with a younger man.
He said he wanted to make people realise there were still countries in the world where the horrific punishment is dealt out for what are called “moral crimes”.
He added: “If you think about what has tragically happened with Caroline Flack was a sort of metaphorical stoning and it’s got to stop.
“We’ve treated women horrifically, if you think about MeToo and the women abused by Weinstein.”
Ansari said they decided to work together on the play after Cox saw her emotional response to the script. “He saw this monologue and said, ‘I want to direct this’, and he’s never said that before,” she added.