Without a minimum duration, you can cancel your rental contract three months after notice is given (Kündigungsfrist).
Update: Jan 2014
If are able to find a new adequate tenant to take over your flat, your landlord might be willing to let you cancel your rental contract with short notice. Please check the particular conditions in your rental agreement.
Furthermore, in Germany, a change of job does not usually entitle tenants to an exceptional right to cancel a rental contract.
Don’t forget to ask your landlord for the refund of your rent deposit (along with its interest) before leaving Germany.