How to choose optocoupler
Start by choosing a "gate drive" push-pull optocoupler and you almost can't go wrong.  I would choose one with a supply voltage of 30 volts or so to give yourself some margin running a motor.  You may need a resistor on the input side to limit diode current.  The PC817 you have chosen is a poor choice for anything except a low speed, on-off switch because when you turn it off, you are relying on the 10K pull-down resistor to drive your MOSFET gate.