Thank you for your response.
The required credits with link to the corresponding OK statute can be found in Chapter 11 of the County Sheriff's Handbook available here http://agecon.okstate.edu/ctp/files/County%20Sheriff%20Handbook%202012.pdf
There are at least two credits to which your son would be entitled, see pages 11-11 and 11-12, which are the two credits you mentioned in your original question.
Work credit: Prisoners employed must be given a credit of two days on a jail sentence for each day worked. The County Sheriff is authorized to order the credit be given to the prisoner on the records of the court
where the conviction of the prisoner is filed. Every county prisoner, whether required to work on the public highways or merely confined in the county jail, must receive credit on fines and costs of $1.00 for each day confined in prison, or working; provided that those prisoners performing the most efficient work and making the best prisoners, must be entitled to an additional credit of one day for every five days of work, the guard or custodian of the county jail to determine at the end of each five days of the imprisonment whether or not the prisoner is entitled to the credit, and to make a record of the decision and notify the prisoner. This last credit of the additional day for every five worked seems to be the only one that is discretionary, and it is in addition to the required 2 days of credit for every 1 worked.
The good behavior credit of 5 days credit for every 4 served is also required provided the prisoner has obeyed the rules and regulations of the county jail in a satisfactory manner.
There is no indication in the handbook or statutes that these are alternate credits and the Sheriff has no discretion to deny the credits other than on the grounds that the prisoner is not qualified to receive them under the terms of the statute.
To file a federal habeas corpus petition, the prisoner must first exhaust all available administrative and state court remedies. A prison or prison system's regulations define the steps a prisoner must take to properly exhaust administrative remedies and a prisoner may only exhaust by following all of the steps laid out therein. Generally, there is an opportunity to appeal to the court. If not, and the person becomes illegally detained - meaning the sentence has gone on longer than it should under the proper calculations - he could file a motion for state habeas corpus relief in the District Court of the county where petitioner is restrained. See Rule 10.6 Rules of Court of Criminal
It is unlikely he could file a civil lawsuit to recover damages based on the negligent calculation of the credits, as government officials would receive qualified immunity for such actions done while in the performance of their duties.
Please feel free to ask any follow-up questions.