I'm not aware of a specific legal limit set by the EU legislation, but the BRC Standard for Food manufacturers says that Industry Best Practices should apply with regard to the product, the foreign material, the placement and the sensitivity of the equipment.
That is still vague, of course, but I interpret that to mean that you need to aim to detect what is reasonably feasible to detect in the product you produce with current technology. For metal detection this is typically around 2-3 mm or less. For X-ray detection of other materials, this can sometimes run up to 5-6 millimeter. Note: that the density of your product, any packaging, and the specific circumstances surrounding the detection all affect the exact values.
Whatever you do, foreign material should always be detected at sizes smaller than 7 mm. A detection system that only detects foreign material of 7 mm or larger is going to get rejected by customers and auditors alike.
Do you produce a specific product? If you share that, other people in the same industry could share industry standards with you for what is reasonably expected.