You are correct, there was a 2nd Lt. William Porter in Captain John Patterson's Co D, 3rd OH. He was age 25 [born 1821] when he enlisted. he was appointed Corporal 2 Jun 1846; First Sergeant 31 Jul 1846; promoted to Second Lieut 31 Aug 1846; mustered out with company June 18, 1847. No pension record.
Another William Porter was in Captain James F. Chapman's Company F, 3rd Ohio, was age 43 [born 1803]. No pension.
There was also another William Porter in Captain Asbury F. Noles' Company H 3rd Ohio, age not given, no further record found.
If William died during the war, he would be listed in one of the military records. None of the three Porters here were so reported. If he died and left an indigent widow or with minor children, there would be a pension request.
If you are sure your William was in the 3rd Ohio, you might enjoy reading Col. Samuel Cutis's diary in "Mexico Under Fire" edited and annotated by Joseph E. Chance.