Most work on wireless network resource allocation use physical layer performance such as sum rate and outage probability as the figure of merit. These metrics may not reflect the true user QoS in future heterogenous networks (HetNets) with many small cells, due to large traffic variations in overlapping cells with complicated interference conditions. This paper studies the spectrum allocation problem in HetNets using the average packet sojourn time as the performance metric. To be specific, in a HetNet with K base terminal stations (BTS's), we determine the optimal partition of the spectrum into 2K possible spectrum sharing combinations. We use an interactive queueing model to characterize the flow level performance, where the service rates are decided by the spectrum partition. The spectrum allocation problem is formulated using a conservative approximation, which makes the optimization problem convex. We prove that in the optimal solution the spectrum is divided into at most K pieces. A numerical algorithm is provided to solve the spectrum allocation problem on a slow timescale with aggregate traffic and service information. Simulation results show that the proposed solution achieves significant gains compared to both orthogonal and full spectrum reuse allocations with moderate to heavy traffic.