I have a Google Apps account, with 2-step verification, set up in Apple mail. Typically it works great for several weeks, or a month, but then the SMTP server has (Offline) next to it, and it will refuse to send from that email address. I still can receive mail into that account. I believe deleting the account from Mail.app and adding it back in fixes the problem for awhile, but is there something that I should look for in the configuration of this account that has problems in particular?
Are you sure google isn't simply kicking you out after a month or so, because you have to refresh your two factor auth login?
SMTP uses password authentication, and two factor auth sets up your account so that a password alone is not enough to access your account.
I think this is unlikely to be a problem with mail.app, and deleting/re-creating the account is a red herring. The real issue is happening on google's server and something else is solving it. Deleting the account in Mail.app and creating a new one with the same username/password has no impact at all on what data it sends to google's server, so it's impossible for that to solve the problem you're having.
Perhaps if you log into google in safari, go through the two factor auth process, Mail.app will suddenly start working again? I'm not sure how google's two factor auth uses, I think if you have used two factor auth from that IP address recently, it will accept password-only authentication.
Failing that, you might have better luck on a google specific support forum, or just waiting for it to be fixed (you can't be the only person experiencing this issue).
I'm doubtful this is your issue, but note that the password for the SMTP server is configured independently from the incoming (IMAP) server. Double-check both are set to a valid app-specific password in Mail.app's settings.
FWIW I've been having this problem with my account since setting up two-factor-auth. I've had to reset my app-specific password for the GMail account on my mac profile several times. The most recent time I actually just needed to restart Mail.app though.
Worth checking that you aren't suffering from a Captcha-based issue. See here.
I have this same problem as of this morning (9/30/15) after upgrading to Yosemite on my Macbook Pro. It worked fine for one day. Can receive but not send as the account is offline. I've tried every tip I've been reading about and nothing is working. I can send emails from my Mac if I go on the internet to mail.google.com. The problem is with MacMail.