Striking of breast is a reflex action of human body, and may trace its origin to Adam and Eve when they found their son Abel dead, or even earlier, when they were cast out of Eden. When a person goes short of breath- whatever be the reasons- the heart needs stimulation in order to pump better. For instance, when children cry loudly demanding something, they may fall short of breath which provokes them to beat the breast. A lady mourning the death of her husband cries aloud and beats the breast for the same reason.
During the process of resuscitation, the chest of the patient is pressed in a rhythmic manner so that he is able to breathe.
Somehow, beating of the breast got associated with expression of sorrow, over a period of time across nations and in religious practices.What we have during the recital of prayer of penitence, is a replica of the practice , meant to express publicly, our sorrow for having hurt God through the sins. One may never be able to trace the origin of its formal induction in prayers.
PS: In some places of India, there live a tribe named Rudali, the women of which are professional mourners. They loudly cry and beat the breast at any home where someone is dead, at a reasonable fee. Shia Muslims beat the breast to express sorrow during the Muharram procession, to commemorate the martyrdom of a religious leader.