Quick search by citation:

17 U.S. Code § 505 - Remedies for infringement: Costs and attorney’s fees

In any civil action under this title, the court in its discretion may allow the recovery of full costs by or against any party other than the United States or an officer thereof. Except as otherwise provided by this title, the court may also award a reasonable attorney’s fee to the prevailing party as part of the costs.

Historical and Revision Notes
house report no. 94–1476

Under section 505 the awarding of costs and attorney’s fees are left to the court’s discretion, and the section also makes clear that neither costs nor attorney’s fees can be awarded to or against “the United States or an officer thereof.”