How does wind affect the airspeed that I should fly for maximum range in an airplane?
My answer was rather concise first, and I got the impression that I need to elaborate the question first. The question is about the best airspeed for maximum range. With wind. Best range means you cover the most distance while the wind is carrying the plane with it. If you have a headwind, the longer you stay aloft, the more you are carried back, so you better hurry up. With a tailwind, it helps to slow down because now the wind is helping you to cover even more distance.

But how much? We need to pick that particular speed where the change in fuel consumption just balances the change in speed over ground. I always found that easier to explain with gliders, and there you can really observe which polar point is best. Just picture yourself as an observer on the ground who sees the plane fly by in the distance. If you plot a line with the combination of positions and altitude, there must be one flight speed that produces a line where the flight path angle is the shallowest. This is the desired optimum. That has only little to do with optimum L/D - this is just one other point you can find with a sink speed polar. And it happens to be the point for best glide in still air. But there is so much more that humble polar will tell you, if you look at it the right way.

With powered aircraft you need to pick the polar point where your fuel flow is lowest for the given speed over ground. Basically, you fly like the glider and add enough power to stay at the same altitude. That is all the difference. User2168 has answered that part already with a graphical solution.

OK, now back to gliders. Please look at the plot below which shows airspeed on the X axis and sink speed on the Y axis.


The solution is graphical: You start on the X-axis at the point which corresponds to the wind speed and put a tangent on the sink speed graph. Where the tangent touches the sink polar (blue line), the plane flies at the best L/D for that given wind speed. Move the starting point to positive speeds for headwind and to negative speeds (not shown here) for tailwind. If the term "best L/D" is already reserved in your mind, please read this as the "best polar point". It is really the same.

Since User2168 has beaten me to the graphical solution, I will add an analytical solution.

For powered flight things become more tricky, because thrust changes with speed. To simplify things, we can say that thrust changes over speed in proportion to the expression $v^{n_v}$ where $n_v$ is a constant which depends on engine type. Piston aircraft have constant power output, and thrust is inverse with speed over the speed range of acceptable propeller efficiencies, hence $n_v$ becomes -1 for piston aircraft. Turboprops make some use of ram pressure, so they profit a little from flying faster, but not much. Their $n_v$ is -0.8 to -0.6. Turbofans are better in utilizing ram pressure, and their $n_v$ is -0.5 to -0.2. The higher the bypass ratio, the more negative their $n_v$ becomes. Jets (think J-79 or even the old Jumo-004) have constant thrust over speed, at least in subsonic flow. Their $n_v$ is approximately 0. Positive values of $n_v$ can be found with ramjets - they develop more thrust the faster they move through the air.

Now for fuel flow: This goes up and down with the power output of the engine. Again a simplification, but it helps to get to grips with the problem and gives useful results. This lets us re-formulate the problem as: At what airspeed do I have the best ratio between power and ground speed? 

Mathematically, we want to fly with $\frac{P}{v_w+v}$ at the lowest possible value. $P$ is the power, $v_w$ is the wind speed and $v$ the airspeed. To express the thrust behavior over speed, I break P up into a product of a constant $K_S$, the throttle setting $\delta$ and the speed like this: $K_S\cdot\delta\cdot v\cdot v^{n_v}$. Here is the general solution, pasted as a PNG to save me all the typing in the editor:


Please note that implicitly the lift coefficient is on both sides of the equation. To solve it, you need to do it recursively, until speed and lift coefficient match. I took this form because of the similarity to the general form at still wind which can be found in many performance books. This here I didn't find anywhere, and it took me a while to figure it out. Thank you, Lnafziger, for the excellent question! It gave me a chance to learn something.

Now I have put the results into a plot. In order to eliminate the aircraft-specific parameters, it shows the ratio of $c_L$ with wind over $c_L$ without wind. The plot is metric, but will work for all units if you use the same units for wind speed and air speed.


To give an example for the application of the correction factor: If you are flying in a 20 m/s headwind and your best range speed at still wind is 50 m/s (approx 97 kts), the $c_L$ needs to be 70% of the $c_L$ at still wind for piston-powered aircraft. This makes your corrected airspeed 60 m/s (v is proportional to $\sqrt{c_L}$), and now the recursive nature of the formula rears its ugly head. At 60 m/s, the correction is only 77.5%, so we need to do a few loops until we arrive at a point where the airspeed and the correction factor match. In this example, this would be 57 m/s or 110 kts in case of a piston-powered aircraft.