They don't learn many languages quickly as in a James Bond film. Dareth touched upon the fact that they either already know a language fluently or they would major, as in any college curriculum in one language - perhaps a couple of dialects. CIA more than likely has various degrees and therefore places to send their agents to depending on the language's usage. If the agent is in Langley at a desk job reading a countries newspapers all day long, they would probably go to a classroom type setting whereas someone in Clandestine Services would have to go directly to the country of origin and spend time with a local family so that if in the field there would not be a shred of doubt as to their true allegiance. In other words their very life could depend on how well they speak that countries language and even a particular region's dialect. Their vocals, nuances, mannerisms and cultural flare would all have to be impeccable to blend in successfully. The higher the degree of fluency would give better odds to more critical assignments.
The majority of folks in the secret services have already studied or worked abroad, or have English as a second language already. Some folks simply have quite an ear for languages and can catch on quickly, although I am sure the CIA has a accelerated learning program for obvious reasons.
When the US Army needs to train people to be fluent in a language and knowledgeable about a culture to send them into the field, they send them to the Defense Language Institute Foreign Language Center in Monterey, CA. This center trains people who are members of the Armed Services (though I'm not sure the CIA sends their people there, they may have a similar program). This institute specializes in intensive language training in particular languages that are of interest for defense work. They have developed special curriculum for learning languages as completely and quickly as possible.