Detecting community structures in social networks is a very important task in social network analysis as these community structures explain relationships among individuals and can be used to predict social behavior. The relationship among subcommunities in each community can further be identified as hierarchical community structures, in which each super node at each hierarchical level represents a nested structure of communities or nodes. Most previous studies attempting to detect hierarchical community structures focused on new metaheuristics that are computationally efficient but do not guarantee the optimal community partition. As a result, this work applies a novel integer programming (IP) approach to detect hierarchical community structures in social networks. This approach has flexible community capacity limits, does not limit the community numbers at different levels, and maximizes a quality measure for hierarchical community partition. The proposed IP approach can use existing software solvers to detect hierarchical community structures without implementing an algorithm. Visual analysis of experimental results shows that the proposed model with different settings for level numbers can analyze reasonable and sophisticated hierarchical community structures, such that the relationships between communities at different levels can be elucidated clearly.