For maximum power production, YES.
But, if you have a house with tilted roof that has two sides facing east and west, you could still install a system on your roof. Of course compared to a system where the panels face south, your annual production decrease (just think of if as the east side will produce electricity before the noon, and the west kicks in the production after the noon). This means if you’re connected to a grid, the payback period of the system will extend. If you own a stand-alone system, you will just have less electricity to consume. Picture below shows the tilted rooftop of a house where two sides are perpendicular to east and west.
If your house itself is tilted a little bit (azimuth is not 0), so that no sides of the roof are facing perpendicular to any direction, then you have to be more considerate when aiming to install a system. Let’s consider the house below.
This house is tilted by 20 degrees (the east side is facing north by 20 degrees; the west side is facing south by 20 degrees). You will obviously consider the south side for installing solar panels. The east side is still suitable for solar panels (the azimuth of panels on the east side will be -20 degrees), but this azimuth angle should really be the limit for such situations. Therefore if your tilted roof, on any side, is facing north by more than 20 degrees, then you should ignore that section.
On a flat roof, if the orientation of the building is not strictly N-S, then you have the option of making panels face south. This is a good action if you have enough space on the rooftop. Because if panels are not in the same direction as the orientation of the building, then they will take up more space on the roof. See image below for illustration.
If there’s not enough space on your roof, you could make the panels parallel to the edge of the building, if they will not be facing away from the south by more than 20 degrees (the azimuth should between -20 and 20 for optimum system production).