Shortcode callback should return it’s output and not echo it.
Something like this should work just fine:
function get_loggedin_avatar (){
global $current_user;
$result="";
if ( is_user_logged_in() ) {
get_currentuserinfo();
$result="<a href="https://wordpress.stackexchange.com/myaccount">".
get_avatar( $current_user->ID, 96, left ).
'</a>';
}
return $result;
}
add_shortcode( 'loggedinavatar', 'get_loggedin_avatar' );