The Code of Federal Regulations contains some rules, there is a set of rules for executive branch agencies, and each agency may have it's own rules. In some cases you may have to seek prior approval and there may be disclosure requirements in those instances.
In general, you can't work for businesses who work for your agency or do work that is substantially related to your own government work. For example, if I were an engineer working for NASA, I would go to my ethics officer before taking a position as a consultanting engineer with Boeing or Lockheed Martin. If I were a Postal Service lawyer I would go to the ethics officer before taking a position or a case representing the Direct Mailers' Association. These are fairly obvious conflicts of interest; some are not so obvious.
In my own case, I used to do system development work for my agency, but it was OK for me to do consulting work that was not related to the systems I was working on - in other words, I couldn't go out and help a company build an application programming interface (API) to send requests to our agency system but it is OK for me to set up a small network to support a local real estate office not doing business with my agency.
AFAIK every agency has an ethics officer to help with these questions, as well as post-employment restrictions. My agency even has a "hot line" you can call for quick answers to questions like "this contractor has a pending proposal and he just offered to buy me a drink - what should I do?" (Usually, if you have to ask the smart thing to do is to decline).