Beds, simple beds, cots, straw mats and hammocks are most likely to be found in houses or guildhalls, although they can also be found in the wilderness.
When you have a premium account, you can sleep in beds, simple beds, cots, straw mats and hammocks that are located inside a house or guildhall, by simply "using" the bed. Doing that, your character will be logged off. If you have eaten something before going asleep, your character will regain hp/mp while offline. Also, your character will regain Soul Points no matter if you have eaten or not.
Since Autumn Patch 2012 it is also possible to do offline training when you use a bed, but unlike using a specific Training Statue for a skill you can select the skill you want to train from a popup window.
Note: not all houses have beds on them. Before renting one, make sure you check if that house has any beds.
If you are a free account player, you can still have access to house/guildhall beds by being invited in the respective house, but you cannot sleep on them.
Also beds you see in the "field" (ie: ones that are not found within an owned house or guildhall) can not be used to sleep on.