In any case where there is a conviction and sentence under the provisions of either Section 270 or Section 270a, should a fine be imposed, such fine shall be directed by the court to be paid in whole or in part to the spouse of the defendant or guardian or custodian of the child or children of such defendant, except as follows:
If the children are receiving public assistance, all fines, penalties or forfeitures imposed and all funds collected from the defendant shall be paid to the county department. Money so paid shall be applied first to support for the calendar month following its receipt by the county department and any balance remaining shall be applied to future needs, or be treated as reimbursement for past support furnished from public assistance funds.
Ca. Pen. Code § 270d