That's not quite how freedom of speech works.
You can say whatever you want as yourself*, and the government can't stop you.
If you're speaking as a representative of the government, however, the government can put limits on your speech, just like any employer can. As an example, IBM is well within their rights to fire an employee that badmouths their products while on service calls. A police officer that badmouths the mayor while in uniform can also be fired.
The government can certainly discriminate against employees or potential employees based on their views and political leanings**. I believe I was asked if I was a communist whenever I enlisted in the military.
TL;DR: Erik Barnett, the guy that lives on the corner and has the green lawn flamingos, can say whatever he wants. Erik Barnett, assistant deputy director at U.S. Immigration and Customs Enforcement and attache to the European Union at the Department of Homeland Security, can't.
[*] within various limits, fire in a theater, etc.
[**] imagine the lawsuits for every presidential appointee if this wasn't the case