Heintzelman was born in Manheim, Pennsylvania, to Peter and Ann Elizabeth Grubb Heintzelman. He graduated from the United States Military Academy in 1826 and was commissioned a brevet second lieutenant in the 3rd U.S. Infantry, July 1, 1826, then in the 2nd U.S. Infantry and served on the Northern frontier at Fort Gratiot, Fort Mackinac, and Fort Brady. On March 4, 1833, he was promoted to first lieutenant and served on quartermaster's duty in Florida during the Second Seminole War. On July 7, 1838, he was appointed captain in the Quartermaster's Department, remaining in Florida with the 2nd Infantry until the close of the war in 1842. In 1847, during the Mexican–American War, he joined General Winfield Scott's army in Mexico, taking part in several engagements, for which he was appointed brevet major on October 9, 1847. In 1848–49 he accompanied his regiment around Cape Horn to California, and for several years served in California and the Arizona Territory.