This is such a difficult situation, as obviously no one wants to smell bad but also you do not want to run the risk of offending the person! I think it really depends on a few factors:; how close you are with the person and how often they are smelling bad.
If it is someone you are not that close to who smells bad all the time, honestly maybe just don’t tell them. For example, if it is just someone you occasionally are next to in the hallway or lunch line, it doesn’t make sense to risk them having a bad reaction to your observation or a bad opinion of you just for a few more seconds of fresh air throughout the day.
The same goes for a one-off situation where just for one day someone smells bad. Like if it is after a game or practice and your friend is not smelling too hot, again I wouldn’t risk the encounter going south because it doesn’t matter they are probably going home after anyway. However, if the day of the one-off happens to fall on a big social day like homecoming, definitely tell the person! I would ask the person if they want to go to the bathroom to freshen up and then offer them some perfume or something. But if you have absolutely any reservations in doing so, I would just not say anything because that is your conscience telling you that the risk is not greater than the reward, and it doesn’t really matter. If someone smells bad one day, everyone will probably forget about it by the next because it is not that serious.
But if it is your friend who literally smells every day, buy them some soap or something for their birthday, or maybe get a new friend. Just kidding. Maybe post a review of a good perfume and try to get them to buy it. But if you think it is fully worth it to tell them at the risk of losing your friendship, then go ahead and let them know about their situation. I would try to offer it up as a suggestion rather than a criticism. For example, say, “I think you would smell really good if you showered more or used this deodorant” rather than just saying “you smell bad.”
At the end of the day, weigh the risk and reward in telling someone they smell, as it could very well ruin their day or end your friendship because I think in this stinky situation you will find it is usually not worth it.