I'm having random moments of deep chest pain, once every other day, lasting only 2 breaths. It's a sharp pain beneath my 5th rib, usually after caffeine. What is happening? How can I diagnose this?

Muscular/skeletal. Several issues: 1. Muscle/bone pain is very common in the young, especially if active and reproduced by movement, deep breathing, etc; 2. Sharp-stabbing pain lasting a few seconds is normal and typically indicates transient nerve compression, called the 'precordial pinch'; 3. Caffeine can cause some normal heart rate increase, which can be associated with chest discomfort.
Stitch pain. It sounds like a rib muscle spasm...Called a stitch that occur randomly and re brief intense and sharp. You can see a provider for diagnosis...You can also try homeopathic bryonia and see if that helps.