No. Only the first is natural. It means that you are giving your opinion, even though it wasn't requested. "If the situation arose in which you asked me [what I thought you should do], [I would tell you that I think] you need to relax sometimes".
Using "when" doesn't make sense. It suggests that the person asks you something on a regular basis or that they are going to ask you a question at an unspecified time in the future. On that basis "you need to relax sometimes" doesn't logically follow. "When you ask me, I always tell you that you need to relax" or "When you ask me, I will tell you that you need to relax" would work but don't mean the same as the "If" sentence.
Student or Learner