Age is particularily important in Korean culture. Friend relationship is usually established among people ONLY in the same age. When their ages are not the same, they have bother/sister relationship instead of friend relationship.
When Koreans get closer, their relationship is based on age in such ways. So, asking age is usually to figure out who is older. If you are not in situation developing such brother/sister/friend relationship, asking age is rude. Asking age to a person who is clearly older than you is rude for this reason.
In contrast, western culture and many other cultures, relationship is not based on age. A lot of students simply assume that the age-based culture is the same in Asia, but it is unique part of Korean culture which is not found in China and weak in Japan. Foreign people in Korea usually have hard time in understanding this age-based culture. This age-based culture is significant part of polite culture in Korea. So, anyone who are studying Korean should pay special attention to learn it correctly.
If you want ask age you can say usually to younger people:
몇 살이에요? (Myet sal yieyo?) (how old are you?)
Age is private. So you might want to ask indirect ways. Asking ddi (animal of the year) is a common way:
무슨 띠에요? (Mooseon ddieyo?) (what animal of year were you born?)
Another way is asking the birth year:
몇년 생이신가요? (Myet nyeon sang yisingayo?) (what is your birth year?)
To elders, you are not in friend relationship. So you don't ask age to be a friend. However, if you want to ask age for some other reasons, you can say:
연세가 어떻게 되세요? (Yieonsega eoddeoke doeseyo?) (how old are you? (for elders))