You absolutely can use alternate delimiters for the matching address (/regex/), but you need to tell sed that you intend to do matching with that delimiter. The way you do this is with a leading backslash \. So your command can be:
sed -e '\|somevar|s|foo|bar|' config.h
or just as easily:
sed -e '\%somevar%s|foo|bar|' config.h
Reference: POSIX reference for sed