If your vehicle is found to be a "total loss" by the insurance company paying your claim, you will be compensated by the way of receiving a settlement to 'make you whole.' Typically the settlement you will receive is for the actual cash value of your vehicle before the accident or to the limits of the policy covering the accident.
The way in which the actual cash value (ACV) is determined differs by insurance company to insurance company but usually uses the Blue Book value, cost of purchasing a car in similar condition from a local auto dealer or private party. The condition of your vehicle, mileage, options and equipment are all taken into account when calculating the ACV.
Depending on what you settle the claim for you might have enough money to both pay off your vehicle and put down money on a new vehicle but typically most insurance companies are under no obligation to make this part of your settlement.
For coverage up to the amount you owe on your loan, purchase GAP insurance.