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
On a computer connected to the same network as the printer, open a browser and enter the printer's IP address.
You can check the printer's IP address using the following menu.
Enter the administrator password to log in as an administrator.
Select in the following order.
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.