"And Moses sent them" (Numbers 31:6). The Holy One, blessed be He, said to Moses (in Numbers 31:2), "Take vengeance yourself," yet he sent others. Rather, because he had grown up in Midian, he said, "It is not fitting that I should distress those who did me a kindness." The proverb says, "A well from which you have drunk water—do not throw a stone into it." And why did he send Phinehas before them? He said, "Whoever began a commandment, he is the one who completes it. He turned back My wrath (Numbers 25:11); he shall complete My commandment."
Why Moses Spared Midian and Sent Phinehas to War
Midrash Tanchuma Buber, Matot 5:1
וישלח אותם משה (במדבר לא ו). הקב"ה אמר למשה נקום בעצמך, והוא שלח לאחרים, אלא על ידי שנתגדל במדין, אמר אינו כדין שאני מיצר למי שעשו לי טובה, המשל אומר באר ששתת ממנו מים אל תזרוק בו אבן. ולמה שלח לפניהם פינחס, אמר מי שהתחיל במצוה הוא גומרה, הוא השיב את חמתי, הוא יגמור את מצותי.