There's a balance to find, and it depends on the context. So I have a few levels of answer to your question.
$(1):$ From the instructor's perspective.
If you are seeking help on homework to turn in, then it is entirely up to the instructor to decide what is appropriate. I have had professors who explicitly state that they consider looking on stack exchange to be cheating; others are totally fine with collaboration as long as you type your own solutions. I also had a professor one time who would allow collaborating on regular homework, but also do "special assignments" where you were required to work alone.
$(2):$ From the student's perspective.
The next question is whether seeing others' solutions will actually benefit you, the learner. This is where you discretion and intuition come in. Personally, I always attempt problems by myself, and might look online if I am stuck or have no clue how to begin. Some people vehemently believe that looking at solutions ruins the learning experience, but I disagree. Particularly when entering a new field, the proof methods are foreign, and not necessarily worth re-discovering on your own.
$(3):$ Other thoughts.
It is easy, given the opportunity, to become overly reliant on others' solutions. This is obviously no way to learn, and it might be considered cheating, which is really something you do not want to mess with.
To reiterate, it is very important to always attempt problems before seeking help.
You will develop must better sense of how much of a solution came from yourself versus something you found online. Personally, I have a sense of whether I used someone else's argument/proof as a resource, or whether I really just copied their work.
If you use an online source, and you feel weird about it, email the professor and ask if it is ok. That might sound weird, but I actually have done this, and your professor will might even appreciate your honesty / concern.
An example of using stack exchange I think is appropriate: you are trying to prove that a series converges, and none of the methods you try are working. After an hour of this, you google the question and see that someone suggests using the Weierstrass $M$-test. With this hint, you return to the problem and it becomes straight-forward to complete.
An example of using stack exchange I think is not appropriate: you find a similar problem with an accepted answer. You outline the proof based on the answer, and type up a solution that you didn't put any work into.