Although theZhangMan is basically right, I'd like to explain this a little more deeply.

Kun was originally used to denote great respect, having a translation meaning, essentially "Lord." You can still see this today in Japanese words like taikun, which was used to refer to the feudal warlords of Japan. The kanji literally means "the big you." These men basically went over the head of the emperor and ran things. When liberal American writers read reports from Japan, they quickly picked up on the lingo, and created a folk spelling, "tycoon," by which they meant the rail road barrons and steel barrons, who, they intimated, were secretly running the country.

Anyway, kun has since become more common. It ranks below san on the politeness level, but above chan. Kun implies a level of friendliness. You probably wouldn't call a stranger "name-kun," unless you were either 1) that cool, or 2) a confused gaijin. Kun is used for males who are your age or younger, but not so young as to be cute enough to warrant the usage of "chan." Older males (especially senior citizens and bosses) should always be called "name-san," unless they specifically say otherwise.

Really, you could use kun in reference to a woman, but it would imply that they were something of a tomboy. One of my host-mothers in Japan would call my host sister Takako "Taa-kun," because she was sort of tomboyish. It was affectionate though. Probably built up over several years of Japanese maternal love. Your mileage may vary. Calling your Japanese girlfriend "name-kun" may have less than desirable results.

San, as I have mentioned is used for strangers, social superiors, and women, except for those women who are cute enough to warrant being called "name-chan." Calling an older woman "name-chan," even if she is cute, is probably an act of arrogance. Still, try to feel the mood of the situation; she might like it.

And, since I've mentioned it so much, I'll just mention that chan is used for very young children, animals ("kuma-chan" translating roughly to "Mr. Bear"), and cute things/people. It is extremely familiar. You could call your lover "name-chan," possibly your brothers and sisters, maybe your parents, and maybe your grandparents. Calling a passing woman "jou-chan" is somewhere between saying "Hey, Babe," and making a catcall.