For a commercial airliner, separation will usually be at least 3 miles laterally, or 1,000 feet vertically. In the enroute environment – at higher operating speeds above 10,000 feet and based on the type of Radar and distance from the antennae – a 5 mile rule is applied laterally. This is true in most but not all situations. There are exceptions: see below.
Note also the “or”: it is allowed (and in fact rather common) for two jets to cross paths at the same moment, with one 1,000 feet directly above the other. The 3 miles is only required if the jets do not have at least 1,000 feet of vertical separation.
Pilots
The regulations do not set a specific distance that pilots flying under VFR must maintain from each other. There’s just the following blanket statement:
§91.111, Operating near other aircraft: (a) No person may operate an aircraft so close to another aircraft as to create a collision hazard. (b) No person may operate an aircraft in formation flight except by arrangement with the pilot in command of each aircraft in the formation.
In addition, there is the catch-all “careless or reckless operation” clause:
§91.13, Careless or reckless operation: No person may operate an aircraft in a careless or reckless manner so as to endanger the life or property of another.
Pilots flying under IFR are subject to the same kinds of rules, and are still responsible for maintaining separation from other traffic when in visual conditions. The rules are the same: the pilot is given the discretion of deciding what a “safe distance” is.
Actual distance limits only come into play for the air traffic controllers, who are responsible for providing minimum separation distances between IFR traffic.
Air Traffic Controllers
The set of FAA regulations for air traffic controllers is FAA order 7110.65. These regulations are quite complicated and there are lots of exceptions and corner cases for various scenario. I’ll try to give only the most basic rules here, but note that a full reading of 7110.65 would be necessary to understand all the minutiae.
Vertical separation:
4-5-1 Vertical Separation Minima. In general, 1,000 feet for IFR traffic (with exceptions).
7-7-3 Separation, 7-8-3 Separation, 7-9-4 Separation. 500 feet for VFR aircraft (with exceptions).
Lateral separation:
5-5-4 Minima. In general, 3 miles in the terminal environment and 5 miles in the enroute environment (with exceptions).
Things get more complicated in the following scenarios, and exceptions apply to them:
Oceanic environment (7110.65 Chapter 8).
Approach environment, especially at large/busy airports with parallel runways and special approach monitoring radar. (7110.65 Chapter 3, Sections 9 & 10).
Nonradar environment (anytime the controller is not able to “apply radar separation”) (7110.65 Chapter 6).
For these scenarios the regulations are rather lengthy and complicated, so I would simply refer you to Order 7110.65 in general.
Military
When flying in airspace controlled by ATC, military pilots must follow the same rules as civilian aircraft. ATC will keep them separated according to the rules above. However, there are two main exceptions to this.
When flying in formation, such as for training, aerial refueling, or intercepting aircraft, they are much too close for ATC to provide safety. In these cases, ATC will allow the pilots to fly under MARSA (Military Assumes Responsibility for Separation of Aircraft). In the case of interception, if the fighter pilot is not able to see the aircraft they are intercepting before the minimum separation, they must break off. They can only fly under MARSA if they can actually ensure visual separation.
The FAA can also define an MOA (Military Operations Area). Once military aircraft enter this area, ATC is no longer responsible for them and they are under MARSA. When the aircraft leave the MOA, ATC resumes control. They can still be under MARSA for a formation, but ATC will keep that formation separated from other traffic.
In tactical formation flying, there is no limit. The Blue Angels routinely fly with only 18" separation between the wing tip and the cockpit canopy. Combat aircraft fly a variety of different formation patterns at varying distances, and pilots are extensively trained on each pattern and what the appropriate/safe distances are. (For example, a fingertip formation allows for much closer flying than a line-abreast formation.)