Use an analytical function to tell you which occurance of the deptno the row represents ...
Code:
select
   d.deptno,
   d.dname,
   e.ename,
   Row_Number() Over Partition By
      (d.deptno) dept_row
from
   dept d,
   emp e
where
   d.deptno=e.deptno and
   d.deptno in (10,20)
order by d.deptno
... then use a decode (or case, if you prefer) to include the department in only the first row of that dept's records ...
Code:
d.deptno||' '||d.dname||chr(10)||e.ename
select
   Decode(dept_row,
      1,deptno||' '||dname||chr(10))||
   ename
from
   (
   select
      d.deptno,
      d.dname,
      e.ename,
      Row_Number() Over Partition By
         (d.deptno) dept_row
   from
      dept d,
      emp e
   where
      d.deptno=e.deptno and
      d.deptno in (10,20)
   order by d.deptno
   )
Haven't tested it, but you get the idea