Presuming this is working ok in twentytwelve, then it is not code you need to add in your child theme, but rather to correct code you have written.
I suspect that the problem is that you have not closed a section correctly eg a div is missing a /div, a table missing a /table etc. – this is usually why the sidebar carries on following what the post/page was doing.
have you edited comments.php in any way?
if yes, please post the full code. ( http://codex.wordpress.org/Forum_Welcome#Posting_Code )
posts without comments seem to have an excess </div> in that section.
Hey alchymyth! You were right; I had a div tag placed after have_comments statement; I moved it to right before its endif closing tag and it works fine now. 🙂 Thanks guys!