Generally, the first thing you do is find the longest continuous chain of carbons in the organic molecule. Sometimes, there is a tie between longest chains; so as a tie-breaker, pick the one with the most substituent groups (groups branching off from the main chain).
Once you found your longest chain, find the end of the chain that's closest to a substituent group. The carbon on that end is considered to be carbon 1.
After that step, it's a matter of adding the substituent groups to the name.
CH3 CH3
l l
CH3 -- C -- C -- CH3
l l
OH OH
BTW, the second one is actually 3-methyl-2,3-pentanediol. The longest continuous chain of carbons on that molecule is 5, so it's a pentane derivative. Like Will said, when you have 2 hydroxy groups on the organic molecule, it's called a diol so the suffix is -diol. With the hydroxy groups at carbons 2 & 3 on the chain, this would be a 2,3-pentanediol. There's also a methyl group at carbon 3, so this compound is 3-methyl-2,3-pentanediol.