The Prophet ﷺ said: Command a boy to pray when he reaches the age of seven years. When he becomes ten years old, then beat him for prayer. (Using translation from Abū Dāʾūd 494)
قَالَ رَسُولُ اللهِ ﷺ «يُؤْمَرُ الصَّبِيُّ بِالصَّلَاةِ إِذَا بَلَغَ سَبْعَ سِنِينَ فَإِذَا بَلَغَ عَشْرًا فَاضْرِبُوهُ عَلَيْهَا»