When "主管" is used as a noun, it is usually a title for a position in a private company, who is in charge of a department, e.g., "人事部门主管". It is a very general word, sometimes informal. But if there are "主管" and "主任" in the same company, then often "主管" is of higher position, but not necessarily. I seldom see in the press that "主管" is used as a noun to describe an government officer or nation-owner company because basically they often have more formal titles, which can be "主任" when he or she is the leader of a "中心" or "办公室", and for department X=科/处/局/厅/部/乡/镇/县/区/市/省 is "X长", basically, e.g, "信息化与网络中心主任", "劳动局局长". It is safe to say "政府各部门主管" （leaders of departments of the government）, but in mainland it is often as "政府各部门领导同志". However, it may be used as a verb to describe a government officer, e.g., "陈副市长主管教育。"（Vice Mayer Chen is in charge of educational affairs.）
I believe "主任" is seldom used as a verb. It is mainly used as a noun, which is title of the chief officer of "中心" or "办公室", sometimes "委员会".
The interesting part is, "主任" is not necessarily a leader, but only a high-end professional. "王主任" can often mean an experienced doctor (Physician, surgeon , dentist ...)
So 主管 and 主任, who is more powerful? In a private company, "主管" can be in a higher position, but it varies with companies. But when the 主任 is of government or who works for government, his or her position varies a lot. He or she can be "街道办主任", who is an officer of not-that-high position, in charge of several blocks, or "中央网络安全和信息化委员会主任", who is, well, President Xi Jinping.