PC817's "absolute maximum" collector current is 50mA. It is not capable of driving any 12V fans, not even small CPU cooler fans. If you connected PC817 as shown in your drawing, it's already dead.
You need to do something like this:
The choice of MOSFET will depend on the current rating of your fan.