How to set a link different behavior for logged and non-logged user?

WordPress has a function for this, called is_user_logged_in. You use it like this:

if (is_user_logged_in())
  echo '<a href="https://wordpress.stackexchange.com/questions/353228/account page">link text</a>';
else
  echo '<a href="login page">link text</a>';