At the top of the buddy Pokemon page, there's a text indicating the total distance walked with your current buddy. Right now, I have my starter Pokemon as my buddy and got 19 kilometers walked with him. If I change my Buddy Pokemon, and then later switch it back to my starter, will this distance have reset or will it still be at 19 kilometers and continue from there?
The total distance walked will not change, although current progress towards a candy will.
See screenshots. Deathturtle has 54.3km total and 0.3km progress towards candy. Switching the buddy for a Vulpix then back to Deathturtle resets the progress to 0km but retains the 54.4km total.
(I'm not sure where the extra .1km came from, I didn't move during these screenshots, perhaps a round up)