If it gets hot enough, it will keep cockroaches and other critters away. My compost doesn't usually heat up that much and I usually do have a few roaches in it. If you have an infestation of them, it is probably a sign that something is wrong - the pile is staying too wet, things aren't decomposing, etc. I don't mind the few roaches, because I figure that is where they belong. They are detritovores and are part of the process of breaking things down. One time I was turning compost moving the fresher stuff to a new pile. A cockroach came out of the bottom of the old pile (where there wouldn't be much food left) and zipped right over to the new pile I had just made. I found that oddly reassuring, like it knew its place. You will never find them in your finished compost, because there is nothing left in that for them to eat.