First, if you're concerned, and it sounds like you are, it's worth a call to the advice nurse or doctor.
Some kids develop repeated movements or behavior around that age (12-18 months). They usually go away. It's reassuring if you can distract her into doing other things. Try changing her focus, to a song or maybe going outside for a change of scene. If the shaking and hitting stop when she's focused on something she likes, that's reassuring.
Sometimes kids shake their heads or hit themselves when they are overstimulated. Then, trying to get their attention, and even holding them can be overwhelming. It's just more input-- tactile, mental, emotional, physical-- than they can handle. At times like that, it's best to be quiet-- reduce noise and bright lights and touching as best you can, and just give her a minute to calm down, while you're there in the room with her, but not too close.
I'd say it's best to not make your concern too obvious to your daughter if it seems like she's shaking or hitting herself as a way of communicating with you. If that's the case, ignoring it will make it go away.
Try to observe what she does in the hour or so before she starts the shaking or hitting. Does she rub her eyes? (she could be tired) Did she just eat? Did she just wake up? Is it morning or evening? Maybe there's a pattern that could help figure out the cause.
It's also a good age to make sure she's communicating with you. If she has problems understanding you or problems with social referencing (eg looking where you point, making eye contact), it's a good idea to talk with a pediatrician about her.