When you excavate your footings you will need to reach below the frost line. This is the depth at which the moisture present in the soil is expected to freeze. Once your footings are buried below the frost line the ground will act as a barrier to insulate the soil below the footing from freezing in the winter.
The depth you are required to set your frost footings will vary from region to region across the country. If you live in a warm climate like South Florida where frost rarely ever occurs you may be allowed to place your footings on grade, but in very cold regions like Minnesota and Canada you will need to dig down 48” or more. Always check with your local building inspections department to see what is required in your area. Furthermore you must install footings at least 12” below unsettled soil. If you are building into the side of a steep hill or beside a retaining wall you will have to maintain the minimum distance to grade not only vertically but also laterally. In order to achieve a suitable lateral barrier you may need to dig your foundation much deeper than on a flat surface.