To have the file updated, use the -i
option of sed:
sed -i "/^foo=/s/=.*/=foobarbaz/" test1.ini
From man sed
:
-i[SUFFIX], --in-place[=SUFFIX]
edit files in place (makes backup if SUFFIX supplied)
So you can also do
sed -i.bak "/^foo=/s/=.*/=foobarbaz/" test1.ini