This paper presents FlexGuard, a novel approach for balancing security and performance in 3D Network-on-Chips (NoCs) using dynamic Security-Performance-Availability (SPA) scoring and stochastic routing. To address vulnerabilities in 3D NoCs, including elevator access threats and cryptanalysis attacks, FlexGuard employs a flexible packet prioritization scheme and anonymous source routing. The system categorizes packets into secure (X-Packets), performance oriented (P-Packets), and normal (N-Packets) types, each with tailored routing strategies. A key innovation is the SPA score, which dynamically assesses and balances security, performance, and availability for each potential routing path. FlexGuard incorporates stochastic path selection, lightweight encryption, and virtual channel allocation to ensure deadlock-free routing while maintaining a balance between security measures and system performance. Experimental results demonstrate FlexGuard's effectiveness in enhancing security without significantly compromising network performance or availability.