The First Amendment is absolutely relevant to the question, although it isn't the end of the story.
Generally speaking, a school can establish reasonable rules and regulations for its students and punish those violations with punishments such as detentions, suspensions, expulsions, changes in grades on assignments or in classes, denial of eligibility to participate in extra-curricular activities or to receive school honors, and similar sanctions.
Generally speaking, violations of school rules cannot result in criminal punishments or civil liability not authorized by other laws, and prohibiting profanity is something that cannot be prohibited at least in cases involving adults.
Minors have First Amendment rights to express opinions, although they are diminished in a school setting, and while literally speaking profanity is part of the content of speech, it is often analyzed as a permissible "time, place or manner" restriction instead, especially when minors are present.
Profanity also covers a range of conduct.
Schools have the greatest authority to regulate speech when it is disruptive to the orderly operations of the school, or threatening. Profanity used to provoke or threaten someone, such as the use of a racial slur or an offensive statement about someone's family, could potentially be punished severely based not simply on what was said but because it is part of a larger context of aggression.
In contrast, schools might potentially exceed their legal authority to prohibit profanity defined in such a way as to prevent students from a particularly ethnicity from speaking in ordinary non-provocative terms to each other.
The N-word directed at an African-American student in a predominantly Hispanic school by someone reputed to be a gang leader with an intent to provoke of threaten the African-American students would be well within the school's right to prohibit and punish severely.
But, punishing two African-American students who are friends for using the same word in a friendly context like "Hey, N- how you doing?" "I'm am doing better than fine, N-" might even be construed as discriminatory if punished and deemed to be beyond the authority of the school to prohibit at all, or with anything more than the most minimal sanction.
Limitations on profanity are also more suspect from a First Amendment perspective when used in connection with conduct that is intended to be expressive, such as an art project, or a monologue chosen for a drama class from published stage plays, novels and poems, or when used in connection with protests and political activity.
Often the standard by which school officials are judged in court when a school punishment for some conduct or another is challenged, is whether the school officials abused their discretion and part of that analysis is proportionality.
A school official can be comfortable that issuing a detention to a student, or assigning the student to some undesirable task like picking up litter from a school yard during recess for saying something like "shit" or "fuck" will not be judged to be an abuse of discretion. But, a court might very well overturn a school's exercise of its discretion to punish a students if a student were expelled for saying something like that in a manner that was not part of a more pervasive pattern of disregard for authority and disruptive behavior.
Another factor that influences whether a rule like a ban on profanity is an abuse of discretion to punish in a particular manner is the extent to which there was advanced notice that this was prohibited.
If the school has a clear rule that is familiar to everyone in the student body stating in advance what is prohibited and what punishments are authorized under particular circumstances, that rule is more likely to be held not to constitute an abuse of discretion, than a severe punishment of a student who has no real advanced warning that the conduct is not allowed.
Similarly, the intent of the student is relevant. If a student uses profanity or an offensive term (e.g. "fag") not knowing that it is considered profane or offensive, either out of ignorance perhaps because other students misled him or her about what a word meant, anything more than a minimal punishment would be an abuse of discretion, while even relatively minor use of profanity, calculated and intended to have great negative effects in the context in which it was used, resulting in a severe punishment, might not be an abuse of discretion.
In between, and perhaps justifying only an intermediate punishment, at most, without constituting an abuse of discretion, would be a use of profanity that isn't naive or innocent, but isn't calculated for maximum negative effect either, and just "pops out" based upon what is normal in a student's home life or previous experience even though it is contrary to the norms of this particular school and the student would have realized that upon further reflection.
Is there detailed case law or a statute that spells this out, in great detail? No. Some of this is embedded in custom and social norms that are familiar to judges (usually in the context of what was historically known as a "certiorari petition" arising from a local government quasi-judicial decision). But, I do think that this answer relatively accurately captures how a seemingly vague "abuse of discretion" review standard for school disciplinary actions for students would be likely to play out in real life, and those expectations absolutely do influence how school administrators and teachers impose discipline, in practice.