"Total federal debt can increase in two ways. First, debt increases when the government sells debt to the public to finance budget deficits and acquire the financial resources needed to meet its obligations. This increases debt held by the public. Second, debt increases when the federal government issues debt to certain government accounts, such as the Social Security, Medicare, and Transportation trust funds, in exchange for their reported surpluses. This increases debt held by government accounts. The sum of debt held by the public and debt held by government accounts is the total federal debt. Surpluses reduce debt held by the public, while deficits raise it."
CRS Report for Congress, RL31967
Federation of American Scientists: http://www.fas.org/sgp/crs/index.html