The U.S. last year racked up its smallest budget deficit since 2007, marking an economic shift of fortunes as President Barack Obama and congressional Republicans prepare to face off over legislative priorities this year.

Capped off by a $2 billion surplus in December, the government ended the calendar year with a deficit of $488 billion, $72 billion less than the 2013 tally, according to data from the U.S. Treasury. The federal government uses a fiscal year that begins in October; on that basis, the 2014 fiscal year ended...