1 - The three possibilities are that you have 5, 7, or 11 on your forehead.
2 - If you have a 5, then person A, with 7, sees (5, 5) and concludes that he must have a 3 or 7, but if he has 3 then he reasons that person B sees (5, 3) and would know his number is 5 or 3. B can eliminate 3 because anyone seeing (3, 3) would immediately know he had 5. Since B doesn't know his number, A would conclude that he has 7. Since A doesn't draw this conclusion you know you don't have a 5.
3 - If you have a 7 then person B with a 5 sees (7, 7) and concludes he has 3 or 5, but if he has 3 then he erasons that person A, with 7, sees (7, 3) and would know know his number is 7. Since A doesn't know his number, then B would conclude he has a 5. Since B doesn't draw this conclusion, you know you don't have a 7.
Therefore you have 11 on your forehead.