In order to protect the machines, the metal pieces should be prevented from entering the production line. It is worth to install metal-detector in the middle of the production line to avoid any metal impurity-related damages to your valuable processing machines.
If the product after packaging is too big for the small-size metal-detectors to figure out inside metal objects, you can carry out detection before packaging in the middle of the processing line. That will be effective as well.