How does the human ear guess the source of the sound? Suppose a sound is produced behind you. You can easily tell that the sound came from behind.
Our ear lobes face towards the front and hence traps the sound waves which come from the front. Yet, we can detect that the sound came from behind. We can claim that the sound which was produced behind the person was reflected by some object to enter the ear but now the new question is how does the ear know if the sound was refelected by that object or if the sound was produced by the object?
How does the ear differentiate between the sounds which are produced behind the person and the sounds which are produced in front of the person?
Or in general, how does the ear identify the location of the source?
 A: sounds that enter the outer ear from different directions originating within the half-hemisphere that each ear faces are subject to reflections in the outer ear that are direction-dependent. those reflection patterns are unique for each direction of approach and in this manner the sounds that enter the ear canal are carrying with them an encoding of their direction. The brain deconvolves that encoding and, along with information on the intensity and phase derived from sound signals entering both ears, deduces the direction of the sound source. 
This process does not involve or require movement of the head and can be demonstrated even if one ear is blocked.
The human head in the vicinity of the ear plays a role in this as well and the directional encoding process which includes the effects of the outer ear and the head is referred to in the psychoacoustics field as the head-modulated transfer function or HMTF. 
This description is a simplification of what really goes on but the head-modulated transfer function is a key component in the sound localization process. Note that wearing a behind-the-ear hearing aid eliminates almost all of the HMTF encoding, making it very difficult for hearing-aid wearers (like me) to localize sound sources. 
A: The brain is an excellent computer, and there are inherent programs biologically engineered. For the analogous  reason that one needs at least two loud speakers to get stereophonic sound, two ears are necessary for localization. At my old age, when one ear's hearing has diminished more with respect to the other's, I have trouble localizing sounds.
This description of the processing makes it clearer:

The localization of sound is an essential part of natural binaural hearing. But how can our brain exactly pinpoint a sound source?
Due to disturbances in the air, sound travels in waves. This is why a sound closer to one ear reaches this ear a bit louder and slightly ahead of the other ear. By combining the different information on time and loudness from both ears, our brain can precisely pinpoint a sound source. This makes natural binaural hearing especially helpful for orientation in noisy environments like traffic situations

This goes into analysis, from the abstract:

An essential task for the central auditory pathways is to parse the au-
ditory messages sent by the two cochleae into auditory objects, the
segregation and localisation of which constitute an important means
of separating target signals from noise and competing sources. When
hearing  losses  are  too  asymmetric,  the  patients  face  a  situation  in
which  the  monaural  exploitation  of  sound  messages  significantly
lessens their performance compared to what it should be in a binaural
situation.

It is worth reading the article in wikipedia which also has diagrams. There are several biophysical models utilizing the distinct variables of sound arrival, the physics entering the input parameters of sound, the biology the receptors of the body. There are enough parameters to constrain the various models .

The sound localization mechanisms of the mammalian auditory system have been extensively studied. The auditory system uses several cues for sound source localization, including time- and level-differences (or intensity-difference) between both ears, spectral information, timing analysis, correlation analysis, and pattern matching.

You state:

Suppose a sound is produced behind you. You can easily tell that the sound came from behind.
Our ear lobes face towards the front and hence traps the sound waves which come from the front. Yet, we can detect that the sound came from behind.

Here is a drawing of an earlobe:

Notice the curling bits? The ones on the top right catch the sound coming from behind. The sound waves are not trapped, they are amplified , the way a palm behind your ear enhances the sounds. And the brain's computer is good enough to fit all the parameters arriving on the ears , frequency, amplitude, angular direction to locate the source direction.

We can claim that the sound which was produced behind the person was reflected by some object to enter the ear but now the new question is how does the ear know if the sound was refelected by that object or if the sound was produced by the object?

The primary source for the brain are the  reflections from the earlobes in order to build  a stereo image of sound sources.  That is the function of all those curls. Reflections are secondary data, and can be confused with primary sources, echoes for example .  A cat gets the same location  functionality by turning  around its ears, as they only gather sound waves in a cone.

Or in general, how does the ear identify the location of the source?

By having an inbuilt program which solves for the parameters coming from the ear, as explained in the various links.
This article might be of interest.
A: There are different mechanisms working: For localizing wether the sound-signal came from the left or from the right, the brain uses the different signal-travelling-times that the signal travelled to the ear. If the Signal arives at your left ear at time 0, and at your right ear at time t, then from knowing the velocity of audio signals in air, you can constraint the location of the sound source to a circle arround the axis that goes through both your ears. 
To determine wether the signal source lies behind you, in front of you, above you, or below you, you NEED more information. You might look at this Wikipedia article, which states exactly that: The Cone of Confusion.
This is resolved by 2 things: The shape of the pinna filters frequencies differently, wether they come from the front or from the back. Thus the ear can perceive differences between signals, when it knows the signals before, thus saying that this must be a signals comming from above. This is a mechanism that can be tricked, of course, since the difference in the ear could stem from a difference in the original signal, rather than from a signal frequency filtering, which the signal undergoes when travelling to your ear. 
The other thing that of course happens is: You move your head. You don't have just 2 points of data, but you're hearing and listening all the time. Tilting your head, and moving it, will result in more circles that the sound source could lie on, thus making it easy to determine the actuall position of the source. 
To the question, how the brain can determine wether the sound came from behind and was diffracted into your ear, or wether it was reflected from an obstacle in front of you: In general it can't determine that (That's why echoes are a disturbing thing). If you can decide wether a signal was an echo, or wether it was actually comming from the front, we usually rely on our experience how for example a "normal" human voice sounds, and how an echo sounds. But maybe you know from your own experience that those distinctions are not always that clear. 
