It depends on who is giving notice. For the employee, the statutory notice period is regulated in Section 622 (1) of the German Civil Code (BGB) and, according to the wording, is four weeks. It is important to note that this is not one month, but 28 days. This period always applies to you, unless you have agreed a longer period with your employer.
According to § 622 Para. 2 BGB, other deadlines apply to the employer. These are staggered depending on the length of service. They vary between one and seven months.