The Office for National Statistics (ONS) said the figure was £4.4 billion higher than the same month last year and the fourth-highest figure for October on record.
The October figure was still below economists’ expectations, with experts unanimously forecasting £21 billion in borrowing for the month.
Total public sector spending rose to £91.2 billion in October after central government spending rose by £6.5 billion to £76.8 billion for the month.
The ONS estimated this included around £3bn for the cost of energy support schemes, including £1.9bn for the £400 residential energy rebate payments.
Chancellor Jeremy Hunt said: “It is correct that the government has increased borrowing to support millions of businesses and families during the pandemic and the aftershocks of Putin’s illegal invasion of Ukraine.
Want a quick, expert briefing on the biggest news? Listen to our latest podcasts to find out what you need to know
“But to fight inflation and ensure the economic stability needed for long-term growth, it is crucial that we put public finances back on a more sustainable path.
“There is no easy way to balance the nation’s books, but we have made the decisions necessary to reduce debt while actively taking action to protect jobs, public services and the most vulnerable.”
Meanwhile, public sector revenue – monies garnered by the public sector mainly through taxes – totaled £77.6 billion for the month.
The new data comes days after the Office for Budget Responsibility (OBR) said the national debt for the year will be higher than originally forecast in March.
OBR estimates on Thursday also suggested that higher interest rates mean the cost of servicing debt will double to over £120m next year and make public finances “more vulnerable to future shocks”.