My main thought is that teaching our kids there's a time and a place for certain things is a huge life skill. I'd sit down and tell him that you love and appreciate his personality and sense of humor, but there's a time to be goofy and there's a time to get work done, and remind him that he needs to obey you. Let him know there's plenty of time for him to play and be silly outside of school time.
After that conversation, I'd say make a schedule so he's aware how much time you have allotted to each subject. Sit down with him to do a subject, and let him carry on, and when the time's up, just say, "Well honey, the 15 minutes I had set aside for spelling are over. I'm going to go work on some housework, just let me know when you're finished." And walk away. Sitting there without an audience will likely get boring real fast. You may have a day or so where he sits there for a loooooong time......and where his other activities/privileges have to disappear in order for him to have time to get his school done. But after that, I'd think it would sink in.
Another more outside-the-box suggestion would be wait till there's something he wants- say just before a meal or snacktime- and you can stand there in the kitchen in front of him with the steaming bowl of macaroni or the yummy granola bar in your hand and crack knock-knock jokes for a loooooong time. When he gets REALLY frustrated with you and wants you to knock it off and give him his snack NOW, you'll have a great teachable moment conversation about him knowing now how YOU feel. :)