There are different reason rosemary plant starts dying due to lack of water, direct sunlight, and excessive supply of water. To control the plant from dying, you can touch the soil to find out the status of soil whether it is dry or moist.
Place the plant where it gets indirect sunlight. These are the ways how you can save a dying rosemary plant.