Here's the LTspice simulation of a simple opto circuit that should do what you want.
I didn't include the switch (which should be in the hot, not neutral lead) but just turned the AC on and off in the V1 AC source to simulate the switch action.
Unlike Nigel, who does not use simulators, I have used them for over 30 years and find that a Spice simulation usually gives a good approximation of the real circuit operation as long as you take care not to simulate the devices outside their ratings (or recognize when they are).
View attachment 113638