Open Spotlight Search (in the top-right corner of your screen) and type "Accessibility."
(Conversely, you can go to your Settings and find Accessibility there.)
Scroll down the left menu until you find "Pointer Control. Select it.
Check the box to "ignore the built-in trackpad when mouse or wireless trackpad is present."
Now, your Mac should seamlessly switch on and off your trackpad when you're using a wireless or Bluetooth mouse.
Check out our other Mac hacks, like how to disable the MacBook Pro Touch Bar.