The name of the farmer is not stated in the song but the dog is named Bingo. "There was a farmer had a dog, / and Bingo was his name-o...".
The original intention that it is the dog and not the farmer's name is made clear in earlier versions of the song. In an earlier version of the song the dog was named "little Bingo". From the 1785 songbook "The Humming Bird":
"The farmer's dog leapt over the stile, / his name was little Bingo, / the farmer's dog leapt over the stile, / his name was little Bingo....".
In the same earlier version of the song from 1785 the second verse also states the farmer named other things besides his dog.
"The farmer loved a cup of good ale, / he called it rare good stingo, / the farmer loved a cup of good ale, / he called it rare good stingo...".
Now, wait a minute...the song says:
There was a farmer had a dog
And Bingo was his name-o
This does not exactly specify that it's the dog whose name was Bingo. It actually could have been the farmer. Even in the above example of "Little Bingo"
"The farmer's dog leapt over the stile, / his name was little Bingo"
It's not specific! It seems like it should be the dog...but was the farmer's name Little Bingo?
We may never know...