A prison officer has been jailed for 15 months after having sex with an inmate in a cell.