In this work, an eavesdropping-aware routing and spectrum allocation approach is proposed utilizing network coding (NC) in elastic optical networks (EONs). To provide physical layer security in EONs and secure the confidential connections against eavesdropping attacks using NC, the signals of the confidential connections are combined (XOR-ed) with other signals at different nodes in their path, while transmitted through the network. The combination of signals through NC significantly increases the security of confidential connections, since an eavesdropper must access all individual signals, traversing different links, in order to decrypt the combined signal. A novel heuristic approach is proposed that solves the combined network coding and routing and spectrum allocation problem that also takes into account additional NC constraints that are required in order to consider a confidential connection as secure. Different routing and spectrum allocation strategies are proposed, aiming to maximize the level of security provided for the confidential demands, followed by an extensive performance evaluation of each approach in terms of the level of security provided, as well as the spectrum utilization and blocking probability, under different network conditions. Performance results demonstrate that the proposed approaches can provide efficient solutions in terms of network performance, while also providing the level of security required for each demand.