Localhost wordpress site redirects to public site

WordPress will try to redirect you to the canonical URL for the site, as set in the database during the initial install. But you can override it in the wp-config.php file by setting the WP_HOME constant:

http://codex.wordpress.org/Editing_wp-config.php#Blog_address_.28URL.29

If WP is installed in a subdirectory, you might also need to set WP_SITEURL.