You can keep a cooked cottage pie in the fridge for up to 5 days before the cooked cottage pie goes bad.
After 3 days though in the fridge the cooked cottage pie starts to go stale so it would be best to eat the cooked cottage pie within those 3 days but it will still be safe for up to 5 days in the fridge.
After 5 days in the fridge the cooked cottage pie can start to grow mold and other bacteria which can make you sick if you eat it.
You could freeze the cooked cottage pie though and it should last a few months before it goes bad.
But it's best to eat the cooked cottage pie even when frozen as soon as possible if you want the best taste and freshness.