I want to install a 220 heater in my garage. The heater draws 31 amps. The run will be 26 feet. Would I use a 40 amp breaker and and N0. 10 wire?
You need 8AWG and a 40A breaker for this equipment
You'll need to run 8AWG for this circuit -- NEC 424.3(B) requires the 125% continuous load modifier to be applied to the nameplate rating of the heater, meaning you need to size the wire and breaker for 38.75A of load.
Two hots and a ground should be fine
Most electric heating equipment runs solely off 240VAC, which means that you only need to provide it with two hots and a ground, unless the equipment installation instructions specify a neutral is required as well. In that case, you'll need to use 8/3 cable for this; otherwise, 8/2 is OK here, given that nothing else can be attached to this circuit anyway.
10 awg wire is only rated for 30 amps. I think your 31 amps is the maximum that the device will draw, but I could be mistaken. For a 40 amp circuit, you'll need a minimum of 8 awg wire.
Not sure of your location or of the codes in your area, but in Tennessee, you'll need 4 conductor wire. 2 hot wires, 1 common/neutral, and a ground.