The sum to which a witness is entitled who attends for the state, and any other legal charges incurred in a case wherein there is a prosecutor, shall be paid by such prosecutor as if he were the plaintiff in the case, unless there be a judgment against the defendant, in which case the same shall be taxed in the costs and paid to the persons entitled thereto, by the sheriff or other officer who may receive the same.
W. Va. Code § 62-5-2