Repeat: you need to double the backslashes if you use double quotes. This is an artefact of the shell's quoting mechanisms, not of
sed syntax as such. If you use the slash as separator, you do need to backslash any slashes which are not separators; but it's better to simply use a different separator character.
Code:
sed "s%\\($name:.:[0-9]*:\\)[0-9]*:\\(.*\\):\\(/.*/.*\\):\\(/.*/.*\\)%\1$answer\2%" /etc/passwd
With single quotes, that becomes
Code:
sed 's%\('"$name"':.:[0-9]*:\)[0-9]*:\(.*\):\(/.*/.*\):\(/.*/.*\)%\1'"$answer"'\2%' /etc/passwd
The variables
$name or
$answer obviously cannot contain the separator character in their values (or you need to escape the values).