A TED Talk is one of many presentations no longer than twenty minutes produced by the TED organization. You can view the variety at http://www.ted.com/. The subjects range from math to philosophy to economics, to multidisciplinary topics. For a class of middle or high school students, a TED talk can enhance a student's understanding of a topic by putting it in a different context. Read this article for some advice on whether using a TED talk in your class is a good idea, or, if you are a student, read this article as some advice for enjoying watching TED talks at home.
Obviously, the first step is deciding whether the content is appropriate for what you're teaching. This is usually fairly simple to determine, but I advise watching the entire video you are considering showing. If only part of the video is relevant, time stamp the relevnt part and only show that segment.
If you do time stamp, note that some students will likely be curious about the rest of the video and want to watch it on their own. For this reason, I suggest giving students a hyperlink which they can follow to watch the video in full.
Some TED talks will be very complicated for students to understand, and may require background beyond the scope of the course. For example, high school economics classes generally do not require calculus beforehand, so using a TED talk about economics that contains calculus is not advised, unless you can skip around the confusing computations and give students the core of information you want them to learn about. Again, time stamping is strongly advised.
The final section is applicable only to teachers.
Perhaps one of the best things you can do with TED talks is assign students to watch all or part of them for homework. This can be an invaluable way for students to look at class content from a new angle. For instance, hearing a marine biologist talk about his work as part of a life sciences class can be infeasible in person, but easy with the help of TED talks.
Although it somewhat depends on the structure and content of the course, you can give students a set of open-ended questions accompanying the video to think about. They can then bring some ideas to class the next day and start a discussion about how the video relates to the content being learned. This is a great place to talk about ethics, the global economy, etc., broader topics that are relevant to the bigger picture of the class you are teaching. And you as a teacher probably want students to see the bigger picture, so why not use TED talks if the students can understand them?