When your heart is beating really fast you need to sit down and try to calm down and relax.
Take deep breaths and breathe in and out slowly and as you do that your heart beat should slow down.
Being scared, having anxiety, being stressed out etc or exercising too hard such as running for awhile can cause your heart beat to increase and simply slowing down and relaxing can eventually slow those heart beats down.
If the heart continues to beat too fast and you haven't exercised or did anything else to cause the heart beat to increase then you may want to see a doctor or go to urgent care or the emergency room.
Too much caffeine and lack of sleep can also cause heart beats to increase and also avoiding too much caffeine and getting more sleep can help keep your heart beating correctly.
Relaxing and taking slow deep breaths is the best way to get your heart beat slowed down.