Houses can be purchased in a number of different cities. They can also be obtained by marrying a spouse who owns one, and a few houses are available for free by either completing certain quests or by making certain choices during specific quests.
Houses are available for sale in the cities of Whiterun, Riften, Markarth, Windhelm and Solitude. Speak to the Steward of each city to purchase them. Some require certain quests to be completed as a prerequisite to being able to buy them.
Potential male spouses who own property are Ainethach, Balimund, Erik the Slayer, Filnjar, Gat gro-Shargakh, Pavo Attius, Quintus Navale, Revyn Sadri, Romlyn Dreth, Vorstag and Perth. Potential female spouses who own property are Aeri, Avrusa Sarethi, Borgakh the Steel Heart, Camilia Valerius, Dravynea the Stoneweaver, Gilfre, Mjoll the Lioness, Muiri, Sylgja, Uthgerd the Unbroken, Viola Giordano and Ysolda.
There are also three houses in Riverwood, one in Markarth, one in West of Riften and one in Raven Rock, which all can be obtained either by completing a certain quest or by performing certain actions during a quest.
If the "Hearthfire" expansion has been installed, empty plots of land can be bought in three areas: Hjaalmarch, Falkreath and The Pale. Homesteads can then be built on these plots.