How can I control the heat when cooking on a campfire?
The key is mostly to cook over coals rather than open flame if you want decent control. This is a principle you find all over slow smoking/BBQ. You start the fire with plenty of wood and let it burn down to a pile of red coals, which you then can cook over with nice control.

Personally, when I want to cook over an open fire, I treat the fire pit as 2 zones: fire and coals. I use the "fire" side for anything where I want an open flame, like roasting marshmallows or hot dogs. As a chunk of wood on that side of the pit burns down to coals, I move it over to the other side, for more controlled cooking.

Another way to handle the variability in campfires is to cook with things with a lot of thermal mass to even the heat out. In practical terms, that boils down to cast iron and clay/ceramics. Whether it's a dutch oven or a little "cave" of fire bricks, these materials spread the heat out so nicely you can often just bury them in the coals and "bake" or "roast" a lot of options that you might not have considered as "camping foods". 

The same is true of other cast iron pans and much of the stoneware from places like Pampered Chef, meaning you can pan fry, saute, and do many of the other more typical "kitchen" tasks over a campfire.

One word of warning regarding this principle though is that it might seem like collecting rocks from a nearby stream to use as the thermal mass is a good idea. It is not. Rocks that have spent long periods under water can crack and/or explode when suddenly heated up.