I believe Spike casts a spell to punish Xander. And he wakes up in the time of the "Scourge" as Spike's slave/pet. Of course, Spike is still present Spike, and has to teach Xander how to be a proper pet. Xander is in denial for the most part and insists her Buffyness will save him, and just doesn't want to believe he's in the past. There's all sort of shenanigans with Xander not going docilely to petdom. Clothing is 'earned', going out is 'earned'. . .etc, etc and for the most part, Xander fails totally in the beginning and spends the majority of the time naked and on his knees in Spike's presence. It's been such a long time since I last read it, that I can only remember vague/general bits.
*** Thanx Bern! You found it. . . http://www.xanderxtreme.com/sub/sub