The BusKill App is super easy to use. It works on Windows, Mac, and Linux. It will automatically turn on screen lock when any USB device is removed. The trade off here is simplicity. There is only one action taken (screenlock) and it can not be customized for specific USB devices (triggers on any). But if those limitations seem OK, then the BusKill App is easy to get going.
Here is the main page for the project:
The code is open source and the GitHub repo is here:
Follow those instruction to install the BusKill App on to your system.
Note that the screen lock is nothing special - it is just whatever OS specific screen lock you have in place. So it's up to you to configure the screen lock to have password protection, etc.