If the recipient was a man and a stranger or superior, a proper response could be "Here is the pen you requested, Sir." or if the recipient was not paying attention when the pen was being delivered, "Sir, (pause for acknowledgment) Here is the pen you requested." This would be very formal and honestly, the average American would have no idea what to make of it.
The phrase "Here you are." while comparatively casual, is acceptable and falls into colloquial use along with "There you go." where 'here' and 'there' are used interchangeably. The phrase is sometimes abbreviated to simply 'here' or 'there' a practice that may be considered rude by the recipient.
If the pen had been dropped or otherwise belonged to the recipient in the first place, the phrase would be different. "Here is your pen." or 'your pen'
In this scenario, however it is the obligation of the recipient to be grateful. The pen can be presented with a wordless smile while the recipient says "Thank You", to which the proper response is "You are welcome."