Numbers 31:14-18 ESV
And Moses was angry with the officers of the army, the commanders of thousands and the commanders of hundreds, who had come from service in the war. Moses said to them, “Have you let all the women live? Behold, these, on Balaam’s advice, caused the people of Israel to act treacherously against the LORD in the incident of Peor, and so the plague came among the congregation of the LORD. Now therefore, kill every male among the little ones, and kill every woman who has known man by lying with him. But all the young girls who have not known man by lying with him keep alive for yourselves.
ESV: English Standard Version 2016