Due to crosstalk-induced interactions among different connections, malicious high-power jamming signals can potentially spread widely in a transparent optical network. Moreover, due to imperfect port isolation in wavelength selective switches (WSSs), present within optical switching nodes, crosstalk also affects the quality of the transmitted signal. Therefore, it is necessary to design an optical network in a way that the effect of crosstalk is minimized, while at the same time keeping the cost and the power consumption of the network low. This is achieved in this work by the design of appropriate WSS placement and crosstalk-aware Routing and Spectrum Assignment (RSA) algorithms in flexible grid optical networks, in the form of an Integer Linear Program (ILP) formulation and a heuristic algorithm analogous to vertex coloring. The objective of the optimization algorithms is to minimize the impact of the crosstalk effect, thus minimizing the impact to the normal operation of the network. The optimization objective is enhanced with proper functions in order to minimize the capital expenditure (CAPEX) and the operational expenditure (OPEX) of the networks investigated in terms of cost and power consumption respectively. Performance results indicate that the proposed algorithms minimize the number of WSSs required to compensate for the crosstalk effect, while only slightly increasing the spectrum utilization.