I had actually posted a question along these lines some years back - our kids’ nanny was going to help them do some back-to-school shopping and I was planning on giving her my credit card to do so. This was 12 years ago. The upshot was that if it got spotted, it might cause trouble. Though of course it’s unlikely to get spotted, unless there’s something truly unusual about the transaction.
I don’t know whether it’s illegal, or merely against the cardholder agreement.