I also ran into this issue. I did not want to download the pre-built wheel as Rajeesh suggested, instead I ran the installation instruction as found in the packages installation documentation: https://pillow-heif.readthedocs.io/en/latest/installation.html
Probably the error comes from an outdated libheif-dev version, following said instalation instructions, I now have version 1.19.5 of libheif-dev, the old version that came with my system was 1.14.2.
After the update of libheif-dev, the installation of pillow-heif with pip worked as a charm.