Your landlord is feeding you a pretty big lie. In Madrid, heating is mandatory from November through May, so they absolutely have to install it. What nobody mentions is the timing: if you complain right now, your landlord could try to blame it on a maintenance issue ("oh, it broke," "I didn't know it wasn't working") instead of admitting they never installed it in the first place. That's why the first thing you should do is make a written complaint, preferably certified or by email, asking them to fix the system within a specific timeframe (around 10 days is good). Make sure there's a record that you asked for it before you take any other action.
As for withholding rent, the others are right that it's risky because technically it's breach of contract on your part, even if it's justified. What you can actually do is file a complaint with the Madrid Housing Agency or open a municipal file directly, and that's what really scares landlords because it comes with fines. You can also document alternative heating expenses (electric heater, radiators, etc.) and then claim those extra costs along with damages for deficient habitability.
The important pitfall nobody mentions: if you complain to the authorities, this could cause your landlord to want to terminate your contract when it comes time to renew. It's not legal retaliation, but it happens. That's why it's worth keeping records of everything and maybe consulting with someone who knows about rentals before you file the official complaint.