How soon after a stapled hemorrhoidopexy can you have anal sex?

Not recommended. Stapled hemorrhoidectomy leaves metal staples in the rectal lining. These eventually spit out but may last for quite some time and may cause severe injury to anything inserted rectally. Check with the surgeon who did the procedure who may be able to remove them if needed and sufficient time has passed since surgery.
Anal sex. It is not clear when this would be safe. You need to have resolution of the main issue here: your hemorrhoids. You should have clearance by the physician that did the procedure.