Outputting custom field query from a plugin to the website header

aside from a few syntax errors in there with your printfs, the crux of the problem is things like this:

$title = get_post_meta( $post->ID, 'title', true );

won’t work in your included file because there is no $post in this scope, You have to globalize $post before you can use it:

global $post;
$title = get_post_meta( $post->ID, 'title', true );