<?php
$recent_comments = get_comments( array(
'number' => 1,
'status' => 'approve'
) );
foreach($recent_comments as $comment) :
$latest_postid_with_comment = $comment->comment_post_ID;
endforeach;
?>
Probably way to compress this code into something smaller. But this will work.