Section 29. If animals have been quarantined, collected or isolated upon the premises of the owner or of the person in possession of them at the time such quarantine is imposed, the expense thereof shall be paid by such owner or person; but if specific animals have been quarantined or isolated under section eight or twenty-one for more than ten days upon such premises, as suspected of being affected with a contagious disease, and the owner is forbidden to sell any of the product thereof for food, or if animals have been quarantined, collected or isolated on any premises other than those of such owner or person in possession thereof, the expense of such quarantine shall be paid by the commonwealth, except that, in the case of any animal quarantined for biting or scratching a person, the expense of such quarantine shall be paid by the county in which the injury was inflicted.