If you're trying to teach them, make the lesson fun. As in many child-related questions, the best answer depends on the child or children in question. I'm not a parent or teacher, but I do remember what childhood in general is like.
Make the child believe that it is worth their time and effort to pay attention. This doesn't mean to force or threaten or even bribe the child. Just make the subject (whatever it may be) genuinely interesting to him or her. This can be done using educational television/movies/games/etc. Engage him/her, so that s/he will want to better understand the subject, and will then give you his/her full, undivided attention. Nurture your child's/student's natural curiosity. Be creative.
Also, it's a good idea to encourage him/her to ask questions, which helps to keep them engaged.
Chat with our AI personalities