There are several answers and comments which talk about how things are in the USA, how things are in the EU, how some companies use the Bradford Factor, and so on and so forth. None of that is relevant to your situation.
You're working in the UK, not in the USA or in the EU, and there the law says.
Employees can take time off work if they’re ill. They need to give their employer proof if they’re ill for more than 7 days.
If they’re ill just before or during their holiday, they can take it as sick leave instead.
That's it. If you're ill then you can take time off. If you're ill for more than seven days in a row (including weekends and public holidays) then you have to go to the doctor to get written confirmation.
Employees must give their employer a doctor’s ‘fit note’ (sometimes called a ‘sick note’) if they’ve been ill for more than 7 days in a row and have taken sick leave. This includes non-working days, such as weekends and bank holidays.
If employees are off work for 7 days or less, they do not need to give their employer a fit note or other proof of sickness from a medical professional.
Now, you may get paid less money for the days you're off sick:
When an employee changes their holiday to sick leave they’re paid Statutory Sick Pay which will count towards the amount of holiday pay they’ve received. The exceptions to this rule are:
- they do not qualify for Statutory Sick Pay
- they were off work sick and being paid ‘occupational sick pay’
Even if you're sick for a long period of time then you still get paid:
Employees who are off work sick for more than 4 weeks may be considered long-term sick. A long-term sick employee is still entitled to annual leave.
Only if you're sick for a long period of time can you be dismissed for it:
As a last resort, employers can dismiss an employee who is long-term sick, but before they can do this employers must:
- consider if an employee can return to work - such as by working flexibly or part-time, doing different or less stressful work (with training if necessary)
- consult with employees about when they could return to work and if their health will improve
An employee can take their case to an employment tribunal if they think they’ve been unfairly dismissed.
To summarise: your boss might not like it, but there's very little that they can do about it. If you get your work done on time then there's no problem. The only thing that they can realistically do to get rid of you if they want to is to make your job role redundant. If they choose this route then they'll have to pay you redundancy.
However, having said that, just because you know your rights doesn't mean that you should have a bad attitude and say to your boss "I know my rights!" in a confrontational manner. I'm not suggesting for one moment that you do have a bad attitude, nor am I suggesting that you would ever say something like that to your boss, but it would be remiss of me to not point it out.
Being pleasant, personable, and professional will obviously get you a lot further. If you're well-liked and good at what you do then most companies will give you a lot of leeway, in my experience.
You mention in your edit to your question that you were legitimately ill on all of the occasions that you took sick days.
My advice to you, therefore, is to obtain a doctor's note for every single sick day that you take in future, and to send it to your boss and to your HR department. Don't wait for them to ask for it (they won't ask for it if you're off sick for less than seven days).
This includes any occasions where you're suffering from "idiosyncratic stress".
Doing this might require you to take even more time off: a visit to the doctor will take time, of course - as it's rare that a doctor is available on the same day that you call for an appointment; and the doctor may well tell you to take more than one day off - for example in the case of stress.
But it might be important to cover your back from now on: your boss obviously doesn't believe that you were ill, so if you worry about how you're perceived and any fallout as a result of that; then you should ensure that any illness is backed up by a medical professional, in order to head off any future issues with your boss and/or HR department.
Appendix: thanks to these useful comments from ColleenV which have helped me improve this answer:
a company can’t prevent an employee from using their sick leave. That doesn’t mean that it’s a good move to use sick leave to take time off because you stayed out too late the night before. There’s more to being successful in the work place than knowing the legal limits of what a company can and can’t do. There are plenty of perfectly legal ways to make it clear an employee is “in the dog house” without actually firing them.
the OP’s boss has noticed enough to mention the problem. Their boss is probably trying to head off future problems, and the attitude that “I’m entitled to it and you can’t legally fire me over it so kick rocks” may not be the best response. There’s a perception that the OP was taking sick leave even though they were well enough to work, and that needs to be handled whether or not that perception is correct.