As living standards rise, people have higher requirements for the quality of duck eggs. The quality of duck eggs is related to their origin. Thus, the origin traceability and identification of duck eggs are crucial for protecting the rights and interests of consumers and preserving food safety. As the world’s largest producer and consumer of duck eggs, China’s duck egg market suffers from a severe lack of duck egg traceability and rapid origin identification technology. As a result, a large number of duck eggs from other regions are sold as products from well-known brands, which seriously undermines the rights and interests of consumers and is not conducive to the sound development of the duck egg industry. To address the above issues, this study collected visible/near-infrared spectral data online from duck eggs of three distinct origins. To reduce noise in the spectral data, various pre-processing algorithms, including MSC, SNV, and SG, were employed to process the spectral data of duck eggs in the range of 400–1100 nm. Meanwhile, CARS and SPA were used to select feature variables that reflect the origin of duck eggs. Finally, classification models of duck egg origin were developed based on RF, SVM, and CNN, achieving the highest accuracy of 97.47%, 98.73%, and 100.00%, respectively. To promote the technology’s implementation in the duck egg industry, an online sorting device was built for duck eggs, which mainly consists of a mechanical drive device, spectral software, and a control system. The online detection performance of the machine was validated using 90 duck eggs, and the final detection accuracy of the RF, SVM, and CNN models was 90%, 91.11%, and 94.44%, with a detection speed of 0.1 s, 0.3 s, and 0.5 s, respectively. These results indicate that visible/near-infrared spectroscopy can be exploited to realize rapid online detection of the origin of duck eggs, and the methodologies used in this study can be immediately implemented in production practice.