Peter's explanation is correct. You need to be qualified to teach the specialty, but you usually do not have to have the formality of having the specialty itself to be so qualified. I am going to correct one of his examples, though. I am certified to teach the Cavern Diver certification, but I do not have the PADI cavern diver specialty myself. The requirement is that you must have full cave diver certification to teach the cavern specialty, which (as Peter well knows) is much more complex.