Have Mental Health Questions? Ask a Psychiatrist Online
I am sorry to hear of your pain around this. the best you and her Dad can do is to make her feel safe whether she is with you or with him. Make sure she has her favorite things with her when she goes, a t shirt that smells like you and a picture of you. she is so young that it is hard for her to understand any of this but providing consistency and constancy is what will help her best. If this is handled well by both of you and you don't play our your issues with one another then she can do just fine. You may want to face time with her and tuck her in and tel her she is safe and loved by mommy and daddy.
This is normal for this age...around this time babies have developed object permanency meaning she can hold onto you and feel when you are not there and then this is where stranger anxiety comes in. All babies go through it and this is part of normal development.
Separate from that if she is banging her head on things she is communicating that she is in distress and needs some comfort. I would seek some face to face professional help to have you and your ex sit together with the professional to get the best support for all so that she can begin to feel safe. She can feel safe and you both need to be on board with the plan. Right now it is a change for her and she is reacting with the head banging to show her distress because she doesn't have the words yet to communicate...this is what babies do. But we want to nip that so she can feel safe and calm and maybe give your ex the skills to help calm her and have her feel okay with the change and not being with you during these weekends.