The growth figures are being watched closely for signs of recession - defined as two consecutive quarters of contraction - after the economy shrank in the second quarter for the first time since 2012.
The next quarter runs until the end of September so the August data is the second month in the third quarter.
Although the economy contracted in August, the ONS revised up its forecast for growth in July from 0.3% to 0.4%.
Andrew Wishart, UK economist at Capital Economics, said that this revision meant "fears that the economy is already in recession have been banished".
The ONS said the economy would now have to contract by 1.5% in September alone for the UK to slide in to recession.
What happened in the latest three months?
The ONS uses the monthly data to compile a rolling three-month picture of GDP.
It said that in the first half of 2019 the data had been volatile because of preparations for the original Brexit date in March, which had sparked some stockpiling.
Rob Kent-Smith, head of GDP at the ONS, said: "Growth increased in the latest three months, despite a weak performance across manufacturing, with TV and film production helping to boost the services sector.
"Services provided [the] majority of the growth over the three months, with production and manufacturing falling back," he said.
Over the three months the services sector - which makes up roughly 80% of GDP - grew by 0.4%, following a period of largely flat growth in the previous three months.
The ONS said the production sector fell by 0.4% in the same period, while construction output grew by 0.1%.
For August, economists had been expecting zero growth.
But the ONS data showed it contracted, dragged lower by a drop in manufacturing when car production was subdued.
Only the construction sector expanded during the month, said Chris Williamson, chief business economist at IHS Markit.
Manufacturing contracted by 0.7% while the all-important services sector failed to grow.
He described the August data as "disappointing".