Sex with professor as graduate student
I’ll address you as the graduate student based on the phrasing of the question, hope I’m not being too presumptuous.
In the US, the professor can’t be your advisor if sexual or romantic relations are taking place. They can’t be on your thesis committee. They can’t be teaching a class you’re taking, can’t be supervising you as a TA, can’t be writing you a letter of recommendation, can’t be in any position of authority over you whatsoever, during the relationship and most probably at any time in the future. If none of those things are an issue and you’re a consenting adult, and barring any specific institutional policy to the contrary, you’re in the clear and are free to behave in any way that any other adult is allowed to.
Keep in mind some people in academia would still feel uncomfortable with the situation and may be critical towards you and/or the professor if they become aware of the relationship. Depending on the details, your and the professor’s professional reputation and career may be at some risk. Sex tends to make people uncomfortable, sometimes for good reasons, sometimes not.