During the manufacturing process of the lithium-ion battery, metal foreign matter is likely to be mixed into the battery, which seriously influences the safety performance of the battery. In order to reduce the outflow of such foreign matter defect cells, the production line universally adopted the K-value test process. In the traditional K-value test, the detection threshold is determined empirically, which has poor dynamic characteristics and probably leads to missing or false detection. Based on comparing the screening effect of different machine learning algorithms for the production data of lithium-ion cells, this paper proposes a K-value dynamic screening algorithm for the cell production line based on the local outlier factor algorithm. The analysis results indicate that the proposed method can adaptively adjust the detection threshold. Furthermore, we validated its effectiveness through the metal foreign matter implantation experiment conducted in the pilot manufacturing line. Experiment results show that the proposed method’s detection rate is improved significantly. The increase in the detection rate of foreign matter defects is beneficial to improving battery quality and safety.