The global $authordata
variable is only available by default when $wp_query->is_author() && isset($wp_query->post)
condition is satisfied.
It means that you can’t access $authordata
inside a single post page.
You may try to get author data via $wp_query
:
add_action('wp_head', function()
{
global $wp_query;
$userdata = get_userdata($wp_query->post->post_author);
$avatar_url = get_avatar_ur($userdata->user_email);
...
}, 10, 0);