You need to figure out which wire is which at the box. If you have
only one switch, it must control one wire. The other is usually going
to a switch for the light. If you don't have one, it may be a
permanently hot wire. If that's the case, connect the switched wire to
the fan, hot to the light for the fan if it has one. You will need to
use the pull switch on the fan, if it has one, to work the light.
Alternatively, you can use a wireless remote unit that will work both
and only uses a permanent hot at the box. Personally, I like that
solution, especially for new installs, as it avoids running a wire and
installing a switch.