You can disable the interface that is used to connect the device to the printer. Make the restriction settings to restrict printing and scanning other than via network.
You can also make the restriction settings on the printer's control panel.
Memory Device : Settings > General Settings > Printer Settings > Memory Device Interface > Memory Device
PC Connection via USB : Settings > General Settings > Printer Settings > PC Connection via USB
Access Web Config and select the Product Security tab > External Interface.
Select Disable on the functions you want to set.
Select Enable when you want to cancel controlling.
Click OK.
Check that the disabled port cannot be used.