This saying dates from 1870 or earlier but it was a song by that title in 1934 that gave the phrase a popular boost. One of the best known versions was sung by Elsie Carlisle with Ambrose's Orchestra c. 1934.
One story says the phrase was uttered by Queen Victoria, who had a driver named James Darling. She didn't want to call him "Darling," as custom would dictate, so she called him by his first name instead. I have no idea if this story is true, but I like it.
When I was young I was never sure whether the phrase was "Home James and don't spare the horses" or "Home James and don't spur the horses" - which, of course, would have had the opposite meaning.