SAN FRANCISCO — A federal judge has ordered a former Hewlett-Packard Co. employee to reimburse the company for $165,000 in attorney fees and litigation costs in a rare reversal of typical fee-shifting dynamics.

James Purvis, who worked as an HP sales associate off and on between 2004 and 2008, was one of four named plaintiffs to accuse the company of failing to pay their earned commissions and bonuses. The court granted summary judgment to HP in 2011, which opened plaintiffs up to a unique vulnerability under the California Labor Code. Last week, U.S. District Judge Charles Breyer awarded HP $86,318 in costs and $79,316 in fees, all to be paid out of Purvis’ pocket.