The last time that this happened was in 1964, when Lyndon B. Johnson was elected President without appearing on the ballot in Alabama. Due to infighting in the Democratic primary, the state refused to back electors pledged to Johnson as the national nominee, instead backing unpledged electors who backed Johnson's opponent, George Wallace. This was part of a larger campaign by Wallace, according to reporting from the time:
Without mentioning Gov. George C. Wallace of Alabama by name, Mr.
Meyer makes it clear in his article that he is talking about the
Governor's efforts to create a block of unpledged electors from
Alabama, Mississippi and possibly‐Louisiana and other states. Mr.
Wallace's plan is to withhold votes and so prevent a majority,
throwing the Presidential election into the House of Representatives.
In the primary on May 5, Alabama Democrats nominated Mr. Wallace's 10
Electoral College candidates.
The Governor said yesterday in Cleveland, at the National Governors
Conference, that unpledged elector slates would be on the ballot in
November in more than a dozen states.
Alabama Democrats also refused to place Harry Truman on their state's ballot in 1948, dramatically storming out of the national convention and backing J. Strom Thurman. Alabama was the only state which didn't have Truman on the ballot whatsoever - in the other states in which he was allowed to run, Thurman appeared on the ballot alongside Truman.
Mr. Thurmond led South Carolina's delegation out of the 1948
Democratic National Convention at Philadelphia when he was Governor of
the state. He later won South Carolina, Alabama, Mississippi and
Louisiana as the States’ Rights, or Dixiecrat, Presidential candidate
against former President Harry S. Truman.
In 1892, Grover Cleveland didn't appear on the ballot in five states, Colorado, Idaho, Kansas, North Dakota & Wyoming. Instead, these states either ran a Democratic-Populist Fusion ticket supporting James Weaver, or didn't list the Democrats at all.
Before this, ballots were issued at the state level rather than federally, so there were quite a few occasions where the victor didn't appear on the ballot. According to Smart Politics:
For example, in 1832, the Whig Party failed in their attempt to send
the presidential election to the House of Representatives by backing
regional nominees against Martin Van Buren, in the hopes the Democrat
would not receive a majority of Electoral College votes.
Whig William Harrison carried Delaware, Kentucky, Indiana, Maryland,
New Jersey, Ohio, and Vermont, Daniel Webster carried Massachusetts,
and the party’s southern candidate, Hugh White, carried Georgia and
Tennessee.
In 1856, the newly formed Republican Party did not find its nominee,
John Frémont, on the ballot in a dozen southern states: Alabama,
Arkansas, Florida, Georgia, Kentucky, Louisiana, Mississippi,
Missouri, North Carolina, Tennessee, Texas, and Virginia.
In each of those states, the choice was between Democrat James
Buchanan and American Party nominee and former president Millard
Fillmore.
In 1860, each of the four candidates receiving Electoral College votes
did not compete in at least one state: Republican Abraham Lincoln in
nine southern states (Alabama, Arkansas, Florida, Georgia, Louisiana,
Mississippi, North Carolina, Tennessee, Texas), Democrat Stephen
Douglas in one (Texas), Southern Democrat John Breckinridge in three
(New Jersey, New York, Rhode Island), and Constitutional Union nominee
John Bell in four (Minnesota, New Jersey, New York, Rhode Island).
In addition, in Colorado's first election after becoming the 38th state in 1876, no candidates appeared on the ballot; there wasn't one. Instead, the state's three electors were chosen by the Colorado General Assembly, which picked three electors pledged to Rutherford B. Hayes, who went on to win the Presidency by one vote. A similar scenario occurred in 1868 in Florida; the state's three electoral votes were allocated by the state legislature to Ulysses S. Grant.