Raw milk and pasteurized milk are characterized by a short shelf life, and drinking expired raw milk and pasteurized milk causes illness. In the study, Plantaricin FB-2 (extracted from Lactiplantibacillus plantarum FB-2) was added to liquid milk. By evaluating the microbial growth, acidity changes, protein content, and sensory changes in raw milk and pasteurized milk during storage, it was found that when Plantaricin FB-2 was added at 0.4 g/kg, the shelf life of raw milk was extended by 3 days (7 days if not added). The shelf life of pasteurized milk with Plantaricin FB-2 was extended to 31 days (25 days in the control group), and the optimal amount was 0.3 g/kg. This confirmed that Plantaricin FB-2 can effectively prolong the shelf life of raw and pasteurized milk. This study provides valuable information for the application of bacteriocins produced by Lactiplantibacillus plantarum in raw milk and pasteurized milk to improve their shelf life.