In line systems will reduce the frequecy of contamination before packing and some retailers will require 'end of line' detection regardless.
Yes sometimes it's determined by your customer rather than a standard what is required. What
HACCP requires you to do is to perform a risk analysis and determine what is appropriate for your system and product based on scientific knowledge. You may not, through risk assessment, decide that you do not need a
metal detector in your system.
However if your selling to a retailer that retailer may mandate something like
metal detection. One previous plant I worked at we tested with metal detectors to a certain mm size. We had one customer that required we test to a size that was larger so we were already set because we tested at a smaller size. However we did have one retailer that wanted us to test to a smaller size than we already tested at. Through sharing data and collaboration we had them agree to how we already tested because the size we were looking for was already a "safe" size.
If you were to decide to put a
metal detector inline with your process my suggestion would be just before it's case packed. That is how we used to test it. The product was cartoned and then it passed through a check weigher and then a
metal detector on it's way to the case packer.
The only issue we had was using recycled cardboard for our cartons sometimes there would be metal pieces in the cartons. The positive side to that was we knew that they would not pass through the system. The negative side was there was a lot sometimes, not very often, where many cartons would kick off because of metal in the carton. However seeing as
metal detection on the cartons was a requirement of us receiving in the cartons from our supplier the loss from that went back to our supplier.