S.H.
Does she have post-nasal drip? That can cause coughing too.... when someone is lying down, it gets stuck in the throat (hence gagging).... and you said she sleeps on her tummy... because you have to have her move to her back???
Or Asthma
Or allergies to dust etc.
Or... when she is sleeping... she is not swallowing her saliva... and it can build up in there (hence gagging), then trickle down the throat and make one cough. Especially a child.
This happened to my Son, when he was younger, like that age.
I actually sat there while he napped, to observe what was happening... and that is what was happening...
All the best,
Susan