Can Apple refuse service under warranty if an iPhone presents only some scratches? One morning I found that one corner of my iPhone was hit and there is a scratch on the metal and the small plastic border around the glass. The glass is in perfect shape.

Now, I encounter an overheating problem with the phone and I want to go to Apple but I'm wondering if I could have problems with the warranty due to this.
I have had some personal experience with this type of warranty problem. I had an iPhone 3GS which had stress cracks in the white case. I left the phone in my pocket the day before my genius appointment, and hey presto it went in the washing machnie.

It came out dead! I took it in, told the gyt what had happened, he took one look at the cracks, and replaced the unit.

Legaly with warranties - if there was a problem with the product at the time of purchase you are able to take a refund without any quibble.

Going back to your specfic case, a few scratches on the phone will go down to standard wear and tear, and cannot be expected to be the cause of overheatingt. Obviously if the scratches are deep so deep in fact the phone is in bits then they won't refund or replace.