It is narrated from Sayyiduna Ali (may Allah be pleased with him) that the Messenger of Allah (peace and blessings be upon him) said: "Three types of people are exempt from accountability: (1) The child until he reaches puberty, (2) The sleeping person until he wakes up, (3) The afflicted person until his distress is removed."
Hadith Referenceمسند احمد / مسند الخلفاء الراشدين / 940
Hadith Gradingحکم دارالسلام:صحيح لغيره، الحسن البصري لم يسمع من علي