Either of those should generally work, but the name of the CVar is a string, so it needs to be quoted:
Code:
SetCVar("showQuestTrackingTooltips", 1)
Without quotes, you're passing SetCVar a variable name, but since there is (probably) no variable with that name, SetCVar will either throw an error, or just ignore you.
Also, "f" should be a local variable (put a "local" keyword at the beginning of the first line). Putting "f" into the global namespace is just begging for conflicts -- and if Blizzard ever leaks a global "f" you could potentially break the whole UI, which actually happened with "_" when Cataclysm launched.
Finally, you can shorten things up a bit with ternary syntax.
Code:
local f = CreateFrame("Frame")
f:RegisterEvent("GROUP_ROSTER_UPDATE")
f:SetScript("OnEvent", function(self, event)
SetCVar("showQuestTrackingTooltips", IsInRaid() and 0 or 1)
end)