I have a Nikon 35mm f/1.8G AF-S DX I bought for my Nikon D5100, it's only a couple months old, never been dropped or anything, and it all of a sudden won't auto focus. Anyone know if this is a simple fix or if I should take it in to be repaired?
First, check the AF/M switch on the D5100 camera body. This is at the left-hand side of the camera (from the photographer's point of view) near the bottom, below the lens release button. Make sure it's set to "AF". Similarly check the "M/A - M" focus mode switch on the lens. Make sure it's set to set to "M/A".
Beyond that, see if you can narrow the problem down to just the lens, just the body, or just this particular combination, by trying a different AF lens with the same body, and a different AF body with the same lens.
If you've taken care of those checks and eliminated those problems, and you're sure the lens is correctly seated on the camera body, then the most frequent remaining cause is poor electrical connections between the camera body and the lens.
If you suspect this problem, you can try wiping those connections gently with a lens cloth or a tissue without any coatings. But when doing this it's vitally important not to get foreign matter into the camera body. So using an eraser or something like that to clean the connections is quite dangerous (if you have bits of rubber somewhere inside the mirror cavity, that's not going to be good for image quality).
This last bit won't apply to your D5100 camera, but if you were using a different body that will autofocus with AF and AF-D lenses also, you could do an additional diagnostic step: see if one of those lenses (i.e. autofocus, but not AF-S) will autofocus on your camera body. When that happens it can be a hint that there is a problem with either the electrical connections in the lens mount. Or, for those camera bodies that have them, a problem with the aperture coupling ring.
Try taking off the lens and cleaning the metal contacts. Take a piece of cloth dip it into rubbing alcohol and gently wipe the contacts.