Have you set your Duet to Laser Mode with M452?
As far as I understand, this would mean that the laser will only be on while moving and will automatically turn off when not moving.
I'm still waiting for my laser to arrive, so I have not tested this yet. But maybe that's all you need 🙂
If you're using the laser in a 3D printer (as I think you do), you can change modes on the fly in the tpreN.g files.
So M451 to enable FFF mode in every TpreN.g that's an extruder, and M452 P3 R255 F200 in the tpreN.g for the laser.
If you're going to use M452, make sure to keep mind of this:
Very important! If you use M452 to put your machine into Laser mode and are running Firmware 2.02 or above, you must replace all S parameters in G0/G1 commands in homing files etc. by H parameters. This is because S is now used to control laser power.