Like most things automotive, exhaust header and system design is a science unto itself. You could use empirical data gathered from others to determine the best possible header primary length and diameter  and this is probably the easiest way  or you could calculate it yourself given some basic information about your engine combo.
Considerations

Header primary tube tuning has two basic parameters: airflow requirement and exhaust pulse tuning. Tubing diameter is dictated by flow requirement, which in itself is determined by engine displacement, engine rpm and the addition of a supercharger, turbo or nitrous. Header primary length has to do with timing the exhaust pulses so that the exhaust from one primary helps to suck the gases from an adjacent cylinder. There are a number of different "established" formulas, and each offers a different level of precision and application specialization.
Adjusting Displacement for Boost

This is something that most formulas don't account for, but it's vital if you're using a turbo, supercharger or nitrous. Most formulas (including the one given here) use raw cylinder displacement, but actual displacement depends on volumetric efficiency (how much fuelair charge gets used vs the engine's displacement). First, divide the engine's total displacement by the number of cylinders to get the cylinder displacement. Then, multiply that by 0.80 for a typical street engine or 0.90 for a tuned race engine. For boost pressures under 14 psi, calculate using the exact displacement. For boost levels over 14 psi, divide the actual boost level by 14 and multiply that by the displacement.
Adjusting Displacement for Nitrous

Nitrous is a bit easier, since exhaust requirements go up linearly with the amount of nitrous. First, divide the nitrous kit's horsepower level by the engine's horsepower without nitrous. Then add that figure to your volumetric efficiency (0.80, 0.90 or whatever the boost turns out to be if you're running a supercharger with nitrous). Multiply your nitrousadjusted volumetric efficiency by the individual cylinder's displacement (engine displacement divided by cylinder count) to arrive at your final adjusted cylinder displacement.
Calculating Pipe Length

Look at your camshaft specs and find out how long the exhaust valve opens in degrees at 0.50inch lift. Subtract this number from 360, then multiply that by 850 (we'll call this Figure A). If your engine sees mainly street duty, subtract 3 from the rpm at which peak torque occurs. For a race engine, subtract 3 from the rpm at which peak horsepower occurs. We'll call this Figure B. Then, divide Figure A by Figure B and you have the pipe length in inches. The formula looks like this: ((850 x (360EVO))/rpm  3 where "EVO" equals "Exhaust Valve Open duration at 0.050inch lift."
Diameter Calculation

Multiply your Volumetric Efficiencyadjust single cylinder displacement by 16.38; we'll call this Figure C. Add 3 to your calculated length from Step 4, then multiply that by 25; this is Figure D. Divide Figure C by Figure D and you'll have the header tubes' inside diameter in inches.
Example One  Mild 350

For this example, we'll use a 350cubicinch, naturally aspirated street V8. The exhaust duration at 0.50 checks in at 212 degrees, and peak torque occurs at 2,800 rpm. Being a street engine, it has a volumetric efficiency of 0.80. We'll begin the length calculation buy subtracting 212 from 360 (equals 148), then multiply that by 850 (equals 125,800). Then we'll subtract 3 from our peak torque (equals 2,797). Dividing 125,800 by 2,797 and we end up with a final primary tube length of 44.9 inches.
Next, we'll adjust displacement by dividing 350 by 8 (equals 43.75 cubic inches per cylinder) and multiplying that by our 0.80 VE (equals 35). Multiply 35 by 16.38 (equals 573.3, Figure C). Now, well add 3 to our calculated header length (equals 47.9) and multiply that by 25 (equals 1,197.5) to derive Figure D. Finally, we'll divide Figure C (573.5) by Figure D (1.197.5) to arrive at an inside tubing diameter of 0.479 inch, or about 1/2 inch.
So, for our mildcam, torqueheavy street 350 we'll need headers with primaries that measure about 44 inches long and 1/2inch on the inside of the tube. Bear in mind that most header companies market their pipes by outside diameter; after accounting for the thickness of the metal tube, this actually comes out to about 3/4 inch outside diameter.
Example Two  Supercharged and Nitrous 350

While the 1/2inch primaries given above may seem very narrow, it's appropriate for that particular engine. Lets take that same engine and add a supercharger (bumps the VE up to 1.10) and 100 horsepower worth of nitrous (adds an additional 0.25 VE for a total of 1.35), then add a longer duration camshaft (235 exhaust degrees at 0.50) and calculate header size based on the peak horsepower rpm (6,500).
Substituting these variable for those of our mild street 350, we end up with a header primary length of 16.35 inches and an inside tubing diameter of 1.96 inches. Those 16 1/2inch by 2inch primaries line up fairly well with about what you'd expect for a fullrace 350.
Related Searches
References
 "How to Build and Modify Chevrolet SmallBlock V8 Cylinder Heads"; David Vizard; 1991
 "Turbo: RealWorld HighPerformance Turbocharger Systems"; Jay K. Miller; 2008
 "Turbochargers"; Hugh MacInnes; 1999
 Photo Credit Jason Smith/Getty Images Sport/Getty Images