I don't remember much, just that Spike has to serve some king. Xander is a peasant or something and visits Spike in the castle gardens.
I can't recall the name of the author. I googled the title, but I can't find it.
Found it thanks to meaura_at_home. It's The King's Pet by Poet of Darkness 5.