There are many reasons babies pull their ears.
It could be a sign of infection. For some babies it can be simply because they have "found" their ears or for comfort in the same way as sucking their thumb can be comforting. Babies may pull their ears when they are teething
. Unfortunately the only way to know for sure is with an examination.