If I connect my tv to a pair of powered speakers via optical cable can I control the volume with the tv volume? If the speakers have a volume knob then that would that serve as a "gain" control?
Most TV's made in the last 10 years have the option of having static or variable volume control on the audio outputs. It is going to be an audio option in the TV's settings. You would turn any volume control on the speakers all the way up and set the TV to output variable volume.
I don't know of too many powered speakers that have an optical input unless they are part of a HTiB. Those that do will have a built-in DAC, which you would need if you have speakers without digital inputs but want to use S/PDIF or TosLink. Cheap portable DACs usually run $40 to $60 with better ones with headphone output and higher resolution running $150 and up.
Have you found speakers that connect by toslink cable? I have a bedroom TV and that's its only audio output. No room in the bedroom for an A/V receiver. All the soundbars and small speakers I've found require a headset jack, or RCA audio.