Usually you would use a plugin hook and not edit the files directly... will make upgrading and maintaining much easier in the long run...
In plugin manager look at the hooks newreply_post_complete and newthread_post_comoplete... find those hooks in the php files and any code you add to those plugins will be like they were added to the php files at those hooks.