I was walking the dog

I was walking the dog; the dog barked a lot.

What does the bold part suggest?

Walking a dog or taking a dog for a walk means to walk alongside a dog outside, who is usually on a leash, to allow the dog to exercise as well as urinate and defecate.

“I was walking the dog on a leash, to allow it urinate and defecate at a distance place.”
Is this sentence OK?

There is an English abbreviation, TMI, which means “too much information”. I think you may be guilty of it. People usually know why you are walking the dog. Still, if you want to be explicit, the correct sentence would be:

“I was walking the dog on a leash, to allow it to urinate and defecate at a distant place.”