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
Enter the printer's IP address into a browser to access Web Config.
Enter the printer's IP address from a computer that is connected to the same network as the printer.
You can check the IP address of the printer from the following menu.
Settings > General Settings > Network Settings > Network Status > Wired LAN/Wi-Fi Status
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.