During the war with Mexico between 1846 and 1847, Hoffman was engaged in the march through Chihuahua, the Siege of Vera Cruz, the Battle of Cerro Gordo, a skirmish at Amazoque, the Capture of San Antonio, the Battle of Contreras and the Battle of Churubusco, where he was wounded. On August 20, 1847 Hoffman was brevetted to major for gallant and meritorious conduct in the Battles of Contreras and Churubusco. He was also involved in the Battle of Molino del Rey, the Battle of Chapultepec, and the Assault and Capture of Mexico City. He was brevetted a lieutenant colonel on September 8, 1847 for his gallant and meritorious conduct in the Battle of Molino del Rey.