The increasing complexity and volume of network traffic in modern 5G network environments pose significant challenges to maintain consistent Quality of Service (QoS) across diverse applications. QoS in 5G networks ensures efficient resource allocation, minimal latency, high throughput, and reliable connectivity. However, without accurate network traffic classification, QoS cannot be effectively optimized. This is because different applications have unique performance requirements. Traditional classification techniques such as port-based identification and Deep Packet Inspection (DPI) have become inadequate due to widespread encryption, port masquerading, and privacy concerns. This paper presents a supervised learning-based approach for network traffic classification specifically aimed at QoS optimization in 5G networks. A Random Forest classifier was implemented using flow level statistical features extracted from the MIRAGE-2019 dataset. The system includes an intelligent QoS policy mapping that categorizes applications according to their network requirements including priority levels, bandwidth needs, latency sensitivity, and jitter tolerance. Experimental results demonstrated 89.76% classification accuracy and 0.897 macro F1-score using Random Forest with RandomOverSampler, confirming the model’s effectiveness in accurately classifying encrypted traffic and supporting QoS optimization.