A tenant has the right to quiet enjoyment of their home, so landlords generally need to give notice before coming in. Common reasons include repairs, inspections, and showing the unit to prospective tenants or buyers.
How much notice is required, and in what form, is set by state law and the lease. Many states require about 24 hours' written notice; some require more, and a few set no specific period but still require reasonable notice. Entry is usually limited to reasonable hours.
Emergencies, such as a burst pipe or a fire, generally allow entry without advance notice. Keep a record of every notice you send.