This paper investigates context-driven flow allocation and media delivery in online social networks. We exploit information on contacts and content preferences found in social networking applications to provide efficient network services and operation at the underlying transport layer. We formulate a linear programming framework that maximizes the information flow-cost ratio of the transport network serving the nodes in the social graph. For practical deployments, we also design a distributed version of the optimization framework that provides similar performance to its centralized counterpart, with lower complexity. In addition, we devise a tracker-based system for efficient content discovery in peer-to-peer (P2P) systems based on social network information. Finally, we design a context-aware packet scheduling technique that maximizes the utility of media delivery among the members of the social network. We provide a comprehensive investigation of the performance of our optimization strategies through both simulations and analysis. We demonstrate their significant advantages over several performance factors relative to conventional solutions that do not employ social network information in their operation.