Put a trigger in your template that will replace the {TemplateBinding Foreground} with a "{Binding Background, RelativeSource={RelativeSource TemplatedParent}}" and vice versa when your control is in the selected state.  You can't use TemplateBinding from a setter, so you'll need to use a regular binding with a RelativeSource of TemplatedParent.  Here is an example of a CheckBox with a TextBlock that inverts the colors when checked: 
<CheckBox Foreground="Blue" Background="LightGreen">
    <ContentControl.Template>
        <ControlTemplate TargetType="CheckBox">
            <TextBlock Name="TextBlock"
                        Background="{TemplateBinding Background}"
                        Foreground="{TemplateBinding Foreground}"
                        Text="Text">
            </TextBlock>
            <ControlTemplate.Triggers>
                <Trigger Property="IsChecked" Value="True">
                    <Setter TargetName="TextBlock" Property="Background"
Value="{Binding Foreground, RelativeSource={RelativeSource TemplatedParent}}"/>
                    <Setter TargetName="TextBlock" Property="Foreground"
Value="{Binding Background, RelativeSource={RelativeSource TemplatedParent}}"/>
                </Trigger>
            </ControlTemplate.Triggers>
        </ControlTemplate>
    </ContentControl.Template>
</CheckBox>