Quick Answer
In government contracts, the question is usually not who owns intellectual property, but what rights the government receives to use it. As a general rule, a contractor keeps ownership of its intellectual property, while the government receives a license to use it. How broad that license is depends largely on who paid to develop the work. This differs from commercial deals, where IP terms are negotiated case by case.