"jail" and "prison" are synonyms - the place where criminals must stay. "jail" is more informal but the words are used in the same way.
"detention" is the noun related to the verb "to detain". If the police arrest someone, they probably then detain them for questioning about a crime. It is temporary imprisonment. You can say that they "keep him in detention."
A teacher may give a naughty pupil "a detention". The child must stay at school after the usual finishing time and do some extra work as a punishment. This may only be a UK usage. Others must confirm if it is international.