In addition to the answers Karl and David K have given, it may be worth noting that the phrase can also be used (in the UK, at least) as a mild or jokey admonishment after someone has already taken something without first asking. In this case it is used sarcastically, e.g. :
'help yourself to my chips, why don't you?' - after someone has eaten a chip from your plate.
'I see you helped yourself to the wine' - after someone drank all of your wine.