The baby was found dead with bleeding injuries last evening at Kondekoundanpalayam village, where about 25 families, hailing from Bihar, were staying and working in private textile and coir units.
Police took Sanjith into custody this morning while he was waiting for a bus to go to the railway station.
Police said during interrogation, he confessed to the crime.
He told police that as he found the baby lying alone, he attempted to sexually assault her and when she started crying, he banged her head on the floor, resulting in her death, they said.