While loop with an exception after a count is reached

You can make use of the build in loop counter, $current_post which you can access in the main query with $wp_query->current_post. (Just a note, the counter starts at 0, so post 1 will be 0)

The main query uses WP_Query, $wp_query being the query variable used, so have a look at the Methods and Properties which you can make use of and the uses of these Methods and Properties

Inside your loop, just before endwhile, add the following

if( 2 === $wp_query->current_post ) {
    echo someFunction();
}