wp_localize_script not create variable in head section

Your code looks correct.
alert(wp_ajax.nonce); should display the nonce.
You can also verify the existence of the wp_ajax object via console.log(wp_ajax) in your browser’s Javascript console.

wp_localize_script adds the object(s) to the footer (a call to wp_footer() should be present in the theme’s footer.php file).
It’ll look like so:

<script type="text/javascript">
    /* <![CDATA[ */
    var wp_ajax = {"url":"http://example.com","nonce":"123XYZ"};
    /* ]]> */
</script>