Open Windows Settings by clicking the “Start” button, then click the gear icon. You can also press Windows+I.
Next, click the “Devices” option.
On the “Devices” page, switch to the “Touchpad” category on the left, then disable the option “Leave touchpad on when a mouse is connected.”
From now on, connecting an external mouse will automatically disable your touchpad. Disconnecting the mouse will re-enable the touchpad.