Is there a spell that protects you from ability damage? I am not looking for spells that restore ability points. E.g. the text of borrowed time says:
If you're immune to ability damage, you take 5 points of hit point damage instead.
So, is this example I want to have a spell on me to get the 5 points of hit point damage.
Spell choices to do what you want are limited, so I'm including Wondrous Items in my answer. I hope you don't mind. Prices are purchase, not craft.
For Poison type Damage
You could consider Ointment, Restorative; 4000g for 5 uses. The spell it uses is Neutralize Poison (Cleric 4) which can prevent worsening Damage but not heal it.
Greater Neutralize Poison(Cleric 6) counters Damage from poison and is a Standard Action.
Periapt of Proof against Poison sets you back a hefty 27,000 ea but is a permanent solution.
For Negative Energy (undead etc)
Your GM may or may not allow Death Ward (Cleric, etc 4th-5th level) to prevent it. It works on negative levels but it's unclear whether ability Damage from undead creatures falls under Death Ward's protection against "any negative energy effects". I think most GM's allow it to work, but I'd ask instead of assuming.
Contingency (Wizard/Sorc 6) with Restoration or similar 'when an Ability falls below X' or just when 'x Ability Damages accrue'.
It's not magic but Barbarians can take Renewed Vitality to help themself.
Ring of Inner Fortitude (16,000/42,000/66,000 ea) can mitigate all forms of Damage (and as a bonus Drain) by 2(1), 4(2), or 6(3) until you have time to heal up. If you take 2 Dex and 2 Con Damage, you would effectively not lose anything, the 2(4, 6) applies to each Ability separately.
Stalwart Resolve (Cleric 2) allows you to ignore all Damage to 1 Ability for 1rd/level of the Cleric. It might get you through a fight, at least. Bonus, you could buy/make scrolls or wands of it. Takes a Standard Action to counter one type of Damage, though.
Alternately, refocus on preventing the Damage. Buffing the party's Dexterity and Constitution will help you get hit less and succeed Fort saves more, preventing ability Damage/Drain.