Any foreign person (from the EU or outside) who needs to carry out a financial, tax, or legal transaction in Spain. The most common cases: buying property, receiving an inheritance, opening a bank account, signing an employment contract, setting up a company, or filing tax returns.
If you are only visiting Spain as a tourist, you do not need one.