The Zohar teaches that the letter yud was added to Pinchas' name and the letter hei was added to Yosef's name [see Psalms 81:6] because they were both zealous about the prohibition of cohabiting with a non-Jewish woman. Pinchas killed Zimri and Yosef resisted the persistent attempts of Potifar's wife.
This sheds light on Rashi's explanation why each of the family names included in the census consisted of their paternal father's names with a hei added at the front and a yud at the end: ''The nation would taunt [Israel] saying ''Why do they trace their lineage by tribe? Do they really think that the Egyptians did not have their way with their mothers?''... So God placed His Name upon them, hei at one end and yud at the other, as if to say ''I testify that these people are indeed the sons of their fathers'' [Rashi to Pinchas 26:5]. Thus we see here that the same letters, yud and hei, were added to show that the Jewish people had been moral, like Pinchas and Yosef.
Why is this vigilance attested to by these two particular letters? Our Sages noted that the Hebrew words for ''man'' אישׁ and ''woman'' אשׁה only differ in the letters yud and hei, which spell God's Name.* On this, they remarked ''If a couple is found worthy, the Divine Presence will be with them''. [Sotah 17a] Here we see the Talmudic source that the letters yud and hei testify that God's people are pure and holy.
*When the letters yud and hei are removed, both words spell אשׁ - fire - showing that when God is not present in a marriage, there is fire.
Based on Likutei Sichos Lubavitcher Rebbe