In order to obtain a copy of the source code, you first must be able to stipulate that the government actually has a copy of it. tldr; There's two ways that the government can get a copy: either produce it in house or state in the procurement contract that the contractor producing it must divulge it to the government.
Government Software Development
It is my understanding that government employees / agencies themselves cannot (or should not) directly create 'code' per se. The reasoning behind this is that the government is not there to compete with entities in the private sector, and should procure tangible / intangible goods and services from the private sector where possible.
I was able to find a quote here from 1980 where the White House Conference on Small Business said:
The Federal Government shall be required by statute to contract out to small
business those supplies and services that the private sector can provide. The government should not
compete with the private sector by accomplishing these efforts with its own or non-profit personnel and
Additionally, there's the Federal Activities Inventory Reform Act of 1998 that basically requires executives of government agencies to maintain a list of their functions which they deem to be "of activities performed by Federal Government sources for the executive agency that, in the judgment of the head of the executive agency, are not inherently governmental functions."
However, I believe if an agency had a capable individual or team working for them and could develop small, time saving applications that aren't really applicable to any other segment of the general market then that is fair game for the government to create in-house.
Contracting outside parties for development
That being said, I think the relevant regulation concerning this type of procurement is FAR 12.212:
(a) Commercial computer software or
commercial computer software documentation
shall be acquired under licenses
customarily provided to the
public to the extent such licenses are
consistent with Federal law and otherwise
satisfy the Government’s needs.
Generally, offerors and contractors
shall not be required to—
(1) Furnish technical information related
to commercial computer software
or commercial computer software documentation
that is not customarily
provided to the public; or
(2) Relinquish to, or otherwise provide,
the Government rights to use,
modify, reproduce, release, perform,
display, or disclose commercial computer
software or commercial computer
software documentation except
as mutually agreed to by the parties.
(b) With regard to commercial computer
software and commercial computer
software documentation, the
Government shall have only those
rights specified in the license contained
in any addendum to the contract.
So, no. The government is no more powerful when it comes to getting source code or extra technical documentation from it's vendors than we are in that it cannot force private entities to relinquish that information without a signed contract. The government can, however, stipulate extra conditions in the procurement contract that require such divulgence, but it is by no means necessary for them to do so.
The government has it, so can I force them to show me teh codez?
Regardless, even if the government has a copy of the source code of an application developed by a contractor, FOIA can only be used to target agency records. In the definitions section of FOIA, source code is determined not to be classified as an agency record (emphasis mine):
(ii) Administrative tools by which records are created, stored, and retrieved, if not created or used as sources of information about organizations, policies, functions, decisions, or procedures of a DNA organization. Normally, computer software, including source code, object code, and listings of source and object codes, regardless of medium are not agency records. (This does not include the underlying data which is processed and produced by such software and which may in some instances be stored with the software.) Exceptions to this position are outlined in paragraph (b)(3) of this section.
The paragraph (b)(3) concerning exceptions to the above definition states:
(3) In some instances, computer software may have to be treated as an agency record and processed under the FOIA. These situations are rare, and shall be treated on a case-by-case basis. Examples of when computer software may have to be treated as an agency record are:
(i) When the data is embedded within the software and cannot be extracted without the software. In this situation, both the data and the software must be reviewed for release or denial under the FOIA.
(ii) Where the software itself reveals information about organizations, policies, functions, decisions, or procedures of a DNA office, such as computer models used to forecast budget outlays, calculate retirement system costs, or optimization models on travel costs.