Both of mine did that when they were overtired, along with rubbing their eyes. DD also did it when she was getting tired and wanted to nurse. I didn't ever get the impression that there was any connection to pain, teething, etc.
Kylee, married to my inimitable DH.
Mama to my seraphic sweetheart (3.2010),
my bodacious babe (11.2011),
and impatiently awaiting someone new (8.2013).