Not very easily without testing. However, in MOST cases, when it's a digestive problem, the discomfort lasts for a long time. If it's heart, the discomfort will usually disappear within a few minutes if you sit or lay down. Sitting or laying down will not help with a digestive issue and the pain will continue.
I had to see a specialist because it was believed my problems were stomach related, and my general Doctor wanted me to swallow a camera to find out what was going on. The consultant asked me how long the pains last. When I explained that if I stand still or sit down they go quite quickly he quickly responded with "this is cardiace related, not stomach, there's no need to swallow a camera". I have felt both stomach pains and heart pains and have to admit they do feel very similar indeed, enough to get me worried at times.