It's part of the story of "The Devil with the Three Golden Hairs" found in <PERSON>'s collection of folktales.
You can find a translation of it with the parallel German text here.
The basic synopsis is that the <PERSON> (<PERSON>-child) is prophesied to marry the king's daughter, to the latter's chagrin. The tries to get rid of the kid by having him go retrieve three golden hairs from the Devil's head. In doing so, he converses with three individuals who need help, including a ferryman who is forced to row and can never be free. Once he gets to Hell...
...the Devil was not at home, but his grandmother was sitting in a large arm-chair. "What do you want?" said she to him, but she did not look so very wicked. "I should like to have three golden hairs from the devil's head," answered he, "else I cannot keep my wife."
She decides to help him out. 351
While the Devil was sleeping, she plucked a hair out and told him one of her dreams. (On Wikipedia it says the Devil had the dreams, but the English and German I provided agree it's the grandmother's dreams.) In one of the dreams, she says an ferryman cannot be freed, and the Devil replies:
"What was the dream, then?" asked he [=the devil], and was quite curious. "I dreamt of a ferry-man who complained that he must always ferry from one side to the other, and was never released. What is the cause of it?" - "Ah! the fool," answered the devil; "when any one comes and wants to go across he must put the oar in his hand, and the other man will have to ferry and he will be free."
The story ends with the <PERSON> telling this to the ferryman and then tricking the king into taking the oars:
The greedy King set out in all haste, and when he came to the river he beckoned to the ferry-man to put him across. The ferry-man came and bade him get in, and when they got to the other shore he put the oar in his hand and sprang out. But from this time forth the King had to ferry, as a punishment for his sins. Perhaps he is ferrying still? If he is, it is because no one has taken the oar from him. 54