This is governed by FAR Subpart 27.4, Rights in Data and Copyright, which provides copyright guidance for the civilian agencies and NASA. Additionally, some agencies may have their own FAR Supplements that they follow.
Under the FAR general data rights clause (FAR 52.227-14), the government has unlimited rights in all data first produced in performance of or delivered under a contract, unless the contractor asserts a claim to copyright or the contract provides otherwise. Unless provided otherwise by an Agency FAR Supplement, a contractor may assert claim to copyright in scientific and technical articles based on or containing data first produced in the performance of a contract and published in academic, technical or professional journals, symposia proceedings, or the like. The express written permission of the Contracting Officer is required before the contractor may assert or enforce the copyright in all other works first produced in the performance of a contract. However, if a contract includes Alternate IV of the clause, the Contracting Officer's approval is not required to assert claim to copyright. Whenever the contractor asserts claim to copyright in works other than computer software, the Government, and others acting on its behalf, are granted a license to reproduce, prepare derivative works, distribute, perform and display the copyrighted work. For computer software the scope of the Government's license does not include the right to distribute to the public, and for "commercial software", the Government typically obtains no better license than would any other customer.
Thus, if you get retention of copyright rights you can sell to others commercially. If your contract does not take the rights from you, then you can sell it to anyone you like.
I hope you found my answer helpful, please click on the GREEN ACCEPT button above for my answer. This is necessary for me to be paid for my work and so that I can get credit for assisting you. Your question will not close, and you will still have the opportunity to follow-up if needed. Leaving a bonus and positive feedback is not required, but doing so is certainly appreciated!
If you have additional questions, please keep in mind that I do not know what you already know or don't know, or with what you need help, unless you tell me. Please consider that I am answering the question or question that is posed in your posting based upon my reading of your post and sometimes misunderstandings can occur. If I did not answer the question you thought you were asking, please respond with the specific question you wanted answered.
Also remember, sometimes the law does not support what we want it to support, but that is not the fault of the person answering the question, so please be courteous.
There can also be a delay of an hour or more in between my answers because I may be helping other customers or taking a break.
You can always request me through my profile at http://www.justanswer.com/law/expert-paulmjd/ or beginning your question with “For PaulMJD…”