Sometimes TALL, young athletic men experience spontaneous collapse of a small part of the lung. You could also be experiencing pain from a pectoral muscle strain. It is unlikely the pain is heart related, otherwise it would be constant. If the pain persists or you experience shortness of breath go to the ER.
It won't be the heart itself if it hurts to breath in, unless there is excess fluid around the heart. Usually breathing in causing a pain is muscle associated and it's usually the muscles between the ribs. This can take a long time to resolve.