The option to automatically remove the images from the media gallery when the product is deleted is located in Catalog Settings > Catalog Design > Single Page Design:
Once you check the Remove images when product is deleted, checkbox and save the settings, the images attached to the product will be automatically removed when you delete it.
Please note that the image will be removed from the server and media gallery when:
- It is not used in the content elsewhere.
- It is not used as a featured image elsewhere.
- It is not used in the eCommerce Product Catalog or WooCommerce gallery on any product.