Mining will go on forever, however new blocks will stop being created somewhere around 2130, if my memory serves. (Actually 2140, just checked)
So that is when the 21,000,000th bitcoin is generated?
Though, from what I'm seeing, the speed of which blocks are generated will depend on the available hardware? So how would it be possible to calculate this, considering we have no idea what power hardware will have in the future. Even predicting the power of hardware a couple of years ahead is close to impossible.
Actually, the 20,999,999.99999999th bitcoin, it stops just below 21m.
To answer your difficulty question, about every 2 weeks the difficulty is raised or lowered depending on how fast people are finding bitcoins. The system dynamically adjusts itself to make sure it sticks to that block-every-10-minutes goal.